Ruby Ruport实践—报表参数实现(二)
本例在 Ruby Ruport实践—报表参数实现 的基础上进行改造,实现报表执行定义时报表参数的增、删、改操作
一、修改views/report_executions/edit.html.erb
不仅显示在新建报表执行时保存的报表参数,还可动态显示剩余的参数(这里控制参数最多可定义5个),这样可避免遗忘定义报表参数或需要增加报表参数的现象
<h1>Editing report_execution</h1>
<% form_for(@report_execution) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :execute_code %>:
<%= f.text_field :execute_code %>
</p>
<p>
<%= f.label :execute_name %>:
<%= f.text_field :execute_name %>
</p>
<p>
<%= f.label :report_definition_id %>:
<%=report_definitions_control%>
</p>
<p>
<%= f.label :report_template_id %>:
<%=report_templates_control%>
</p>
<h3>Report Parameters</h3><p/>
<!-- 显示已有的报表参数 -->
<%if @report_parameters.length>0%>
<%for i in 0..@report_parameters.length-1%>
<p>
<%=hidden_field_tag 'parameter_id[]',@report_parameters[i].report_parameter_id%>
Parameter<%=i+1%>: <%=text_field_tag 'parameter_name[]',@report_parameters[i].parameter_name%>
Value<%=i+1%>: <%=text_field_tag 'parameter_value[]',@report_parameters[i].parameter_value%>
</p>
<%end%>
<%end%>
<!--显示其他的参数框,若需要添加参数可在此操作-->
<%for i in @report_parameters.length+1..5%>
<p>
Parameter<%=i%>: <%=text_field_tag 'parameter_other_name[]'%>
Value<%=i%>: <%=text_field_tag 'parameter_other_value[]'%>
</p>
<%end%>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Show', @report_execution %> |
<%= link_to 'Back', report_executions_path %>
二、修改ReportExecutionsController
主要修改cr
相关文档:
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的安装
watie的安装请查看 -> Ruby library的安装
# 使用Watir工具,需要在脚本中加上
require 'watir'
# 创建一个IE的实例
ie = Watir::IE.new
或者在创建的同时直接转到页面
ie = Watir::IE.start('http://www.text.com/')
Watir使用start方法 ......
Ruport官方网站:http://www.rubyreports.org/
本例中将介绍Ruby报表的简单开发
开发环境
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
二、创建数据库
datab ......
Installing Ruby from source is my preferred method, although in Ubuntu Feisty you can supposedly install it with apt-get install ruby
now. Here’s the essential packages needed to get a source build working right though and the process I just went through:
sudo apt-get install build-essentia ......
Update: This post is outdated. All in one installer for 1.9
is ready now, you should use it if you need 1.9 on windows. Get it here
http://rubyforge.org/frs/?group_id=167
Ruby has “all-in-one” installer for Windows, but it is outdated. As
of May 2009, Ruby 1.9.1 is released, ......