我正在尝试用Prawn生成PDF报告,我可以通过传递单个ID轻松地对show动作进行报告,但我想生成一个包含每个记录的报告.像标准的rails scaffold索引页面.使用rails它看起来像这样:
<% @customer.each do |customer| %>
<%= customer.id %>
<%= customer.name %>
<%end%>
Run Code Online (Sandbox Code Playgroud)
简单!
但是我不确定如何用Prawn做到这一点..
就像是:
def index
@customer = Customer.all
respond_to do |format|
format.html
Prawn::Document.generate("customer_list.pdf") do |pdf|
pdf.text "#{@customer.id} "
pdf.text "#{@customer.name} "
end
end
end
Run Code Online (Sandbox Code Playgroud)
这显然是不对的.
有任何想法吗?谢谢.