Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Ruby Ruportʵ¼ù—¼òµ¥±¨±íϵͳ

¿ª·¢»·¾³
OS:WindowsXP
Ruby:Ruby1.8.7
Rails:Rails2.3.5
Mysql:Mysql5.0.9
IDE:Rubymine2.0.1
×¼±¸¹¤×÷£º
°²×°ÒÔÏÂgem°ü
gem install ruport
gem install ruport-util
gem install acts_as_reportable
±¾ÀýÉè¼ÆµÄ±¨±íϵͳ¹¤×÷Ô­ÀíÈçͼ£¨´¿Êô¸öÈËÀí½â£©£¬ÒÔProducts±íΪÀý£º
½ÓÏÂÀ´ÊµÏÖµÄÀý×Ó½«ÀûÓÃeval·½·¨ÊµÏÖ¶¯Ì¬½Å±¾£¬¶Ô¿ÉÄܱ䶯µÄµØ·½Í¨¹ýÊý¾Ý¿â±£´æÔËÐÐʱ´úÂëÆ¬¶Ï
Ò»¡¢´´½¨±¨±íÔËÐÐʱÐèÒªµÄÊý¾Ý±í
Ö÷¼ü×Ô¶¯Ôö³¤
create table report_definitions
(report_definition_id integer not null,
report_code varchar(30),
report_name varchar(240),
report_sql varchar(4000),
basic_model varchar(20),
primary key ('report_definition_id'));

create table report_templates
(report_template_id integer not null,
template_code varchar(30),
template_name varchar(240),
template_content varchar(4000),
template_type varchar(10),
primary key ('report_template_id'));

create table report_executions
(report_execute_id integer not null,
execute_code varchar(30),
execute_name varchar(240),
report_definition_id int not null,
report_template_id int not null
primary key ('report_execute_id'));

create table products
(product_id int not null,
title varchar(100),
description varchar(100),
price int,
primary key('product_id'));
  
¶þ¡¢ÔÚRubyMineÖÐÀûÓÃScaffold·½·¨Éú³ÉÊý¾Ý±í¶ÔÓ¦µÄÎļþ£¨°üÀ¨Model,View,ControllerµÈ£©
Èý¡¢ÐÞ¸Äenvrioment.rb
ÔÚĩβÌí¼Ó
require "rubygems"
require "ruport"
ËÄ¡¢ÐÞ¸ÄProducts.rb
ÔÚÆäÖÐÌí¼Ó
acts_as_reportable
ʹÆäÄÜʹÓÃacts_as_reportableÖÐÌṩµÄ·½·¨
Îå¡¢´´½¨ReportOuptController£¬´úÂëÈçÏ£º
class ReportOutputController< Ruport::Controller
#Code here
stage :data_sheet
def setup
puts "basic_model= #{options[:basicModel]}"
self.data = eval(options[:basicModel]).report_table_by_sql(options[:sql])
end
end
class ReportHtml < Ruport::Formatter::PDF
renders :pdf, :for => ReportOutputController
build :data_sheet do
eval(options[:outputContent])
end
end
class ReportPdf < Ruport::Formatter


Ïà¹ØÎĵµ£º

дµÄÒ»¸öinterÀàÄ£·ÂrubyÕûÊýµÄÐÐΪ

ÎÒÃÇÖªµÀrubyÖжÔÓÚÕûÊýµÄ[],[]=,<<,>>²Ù×÷ÊÇÕë¶ÔÓÚ¶þ½øÖƵÄÖµÀ´ÔËËãµÄ¡£
ÎÒÏÖÔÚдһ¸öÕë¶ÔÊ®½øÖÆÊý²Ù×÷µÄÀ࣬ӵÓÐÕûÊýµÄËùÓз½·¨£¬ÈçÏÂ:
class InterEx
def initialize(val=0)
@val=val
end

def to_s
@val.to_s
end

def [](idx)
self.to_s[idx].to_i
end

d ......

RUBYʵ¼ù—´øÃÜÂë¼ÓÃܵÄÓû§´´½¨¼°ÐÞ¸Ä

¿ª·¢»·¾³
Ruby: Ruby1.9.1
Rails: Rails2.3.5
Mysql:Mysql5.0.9
Driver:mysql-2.8.1-x86-mingw32.gem
IDE:Rubymine2.0.1
Ò»¡¢´´½¨Êý¾Ý±íUsers
ÀûÓÃRubyMine×Ô´øµÄScaffold¹¤¾ß´´½¨Êý¾Ý±íUsers£¬Ò²¿ÉÒÔÊÖ¶¯´´½¨
¶þ¡¢´´½¨ControllerºÍView
RubyÏîÄ¿—>ÓÒ¼ü—>Create Model
Íê³Éºó½«×Ô¶¯Éú³ÉÏàÓ¦µÄÎ ......

RubyϽâ¾öoci8°²×°´íÎóµÄÎÊÌâ

Prepare
1. Download 'OCI 1.x.x.rb' (it's VERY important - execution MUST be *.rb)
2. Download 'oci8lib.so'
Install
1. Copy 'OCI8.rb' to .../ruby/lib/ruby/site_ruby/1.8/DBD/OCI8
2. Copy 'oci8.rb' to .../ruby/lib/ruby/site_ruby/1.8
3. Copy 'oci8lib.so' to .../ruby/lib/ruby/site_ruby/1.8/i386-msv ......

RubyÖÐ%µÄÓ÷¨(°Ù·ÖºÅµÄÓ÷¨)

%{String}  ÓÃÓÚ´´½¨Ò»¸öʹÓÃË«ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´® 
%Q{String} ÓÃÓÚ´´½¨Ò»¸öʹÓÃË«ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´® 
%Q!Some String of “Characters”! <==> ” Some String of \”Characters\” “
%q{String} ÓÃÓÚ´´½¨Ò»¸öʹÓõ¥ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´® 
%q!Som ......

Cassandra in Action with Twitter's Ruby Client

ÓÐÒ»¸öȫеÄÏîÄ¿£¬ÒòΪ¿¼Âǵ½½«À´µÄÊý¾ÝÀ©Õ¹ÐÔÄÜ£¬ËùÒÔ¿¼ÂÇÓÃCassandra×öÊý¾Ý´æ´¢£¬Ç°¶ËÓÃLighttpd + FastCGI + Rails¡£ÔÚʹÓÃCassandraµÄʱºò£¬¾õµÃÓÐһЩ¶«Î÷¿ÉÄÜ´ó¼Ò¶¼ÐèÒª£¬¾ÍдÁËÒ»¸ö¼òµ¥µÄÖ¸ÄÏ¡£ÒòΪÄÚÈݱȽϳ¤£¨16Ò³£©£¬¾ÍŪÁ˸öPDFÎļþ¸ø´ó¼ÒÏÂÔØ¡£
Cassandra in Action with Twitter's Ruby Client.pdf
Èç¹ûÏÂÔ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ