Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

Rubyʵ¼ù—will_paginateʵÏÖ·ÖÒ³

¿ª·¢»·¾³£º
OS:Windows XP
Ruby:Ruby1.9.1
Rails:Rails2.3.5
will_paginate:will_paginate2.3.11
(ÔÚÃüÁîÐÐÖÐÔËÐÐ gem install mislav-will_paginate --source http://gems.github.com )
IDE:Rubymine2.0.1
DB:mysql5.0.9
±¾ÀýÔÚÉÏÒ»¸öÀý×Ó£¨Rubyʵ¼ù—¼òµ¥Êý¾Ý¿â²Ù×÷£©µÄ»ù´¡ÉÏʵÏÖ·ÖÒ³£¬ÀûÓõÄÊÇwill_p ......

ruby on rails Ò»²½²½¿ªÊ¼(2)·ÖÒ³ºÍ¼òµ¥²éѯ

ʹÓà will_paginate ½øÐзÖÒ³ºÍ¼òµ¥²éѯ
ÔÚÃüÁîÐÐÏÂʹÓà gem install will_paginate ÃüÁ³öÏÖÏÂÃæ½á¹û°²×°³É¹¦
´ò¿ª books_controller.rb (Äã×Ô¼ºµÄ¿ØÖÆÆ÷)
×¢Ê͵ô²éÕÒÈ«²¿µÄ·½·¨£¬Ê¹ÓÃÏÂÃæµÄ·½·¨£¬ÒѾ­¼¯³É¸ù¾Ýtitle½øÐвéѯ
Ruby´úÂë
#@books = Book.all   
@books = Book.pagina ......

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
Íê³Éºó½«×Ô¶¯Éú³ÉÏàÓ¦µÄÎ ......

Use lambda in Ruby ¾ÅͲһÌõ

http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
Understanding Ruby Blocks, Procs and Lambdas
Blocks, Procs and lambdas (referred to as closures
in Computer Science) are one of the most powerful aspects of Ruby, and
also one of the most misunderstood. This ......

Watir Óï·¨£¨Web Application Testing in Ruby)

Watir Óï·¨£¨Web Application Testing in Ruby)
# watirµÄ°²×°
watieµÄ°²×°Çë²é¿´ -> Ruby libraryµÄ°²×°
# ʹÓÃWatir¹¤¾ß£¬ÐèÒªÔڽű¾ÖмÓÉÏ
require 'watir'
# ´´½¨Ò»¸öIEµÄʵÀý
ie = Watir::IE.new
»òÕßÔÚ´´½¨µÄͬʱֱ½Óתµ½Ò³Ãæ
ie = Watir::IE.start('http://www.text.com/')
WatirʹÓÃstart·½·¨ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ