2012-03-19 32 views
0

我正在使用gem datagrid显示一些数据。我想用ruport将数据输出为pdf。新手 - 尝试将数据网格保存为pdf

我添加了这个按钮,我controller.rb =

<%= button_to "PDF", {:controller => :admin_reports, :action => :worequest_pdf }%> 

我有这条路线=

resources :admin_reports do 
post :worequest_pdf, :on => :collection 

这在admin_reports_controller.rb =

def worequest_pdf 
f = File.new("worequest.pdf", "w") 
f.write Ruport::Data::Table(:column_names =>report.header, :data => report.rows).to_pdf 
f.close 

end

但是,它不工作 - 任何想法? 我得到:

undefined local variable or method `report' for #<AdminReportsController:0x007fc463566218> 
+1

你有错误?你在服务器窗口(终端)中看到了什么? – 2012-03-19 20:29:38

+0

我得到:未定义的局部变量或方法'报告'为# Reddirt 2012-03-19 21:04:40

回答

0

要克服错误

undefined local variable or method `report' 

你是否应该使用 “@report” 而不是 “报告”?