【发布时间】:2017-04-12 20:26:40
【问题描述】:
我希望使用 Prawn PDF 和 rails 4.2 将所有记录提取到单个 pdf 中。
目前我让它们通过 id 为单个 pdf 生成并且效果很好。
显示
def show
@agreement = Agreement.find(params[:id])
respond_to do |format|
format.html
format.pdf do
pdf = AgreementPdf.new(@agreement)
send_data pdf.render, filename: "Agreement - #{@agreement.entity}", type: "application/pdf", disposition: "inline"
end
end
end
表中的索引
<% @agreements.each do |agreement| %>
<tr>
<td><%= agreement.entity %></td>
<td><%= link_to 'Download', agreement_path(agreement.id, format: 'pdf'), :target => "_blank" %></td>
</tr>
<% end %>
【问题讨论】:
标签: ruby-on-rails prawn