0
我正在尋找使用對蝦PDF和導軌4.2提取所有記錄到一個單一的PDF。對蝦PDF和多記錄記錄
目前,我有他們生成的個人PDF格式的ID和運作良好。
顯示在表
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 %>
你將如何調用視圖中的變量? – DollarChills
我編輯答案並添加視圖和路線。我沒有測試,只是代碼來展示如何去做 –
釘住它。謝謝你的幫助。 – DollarChills