wicked_pdf没有收益率内容

时间:2014-09-16 07:52:09

标签: ruby-on-rails ruby-on-rails-4 wicked-pdf

<%= wicked_pdf_stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= wicked_pdf_javascript_include_tag "application", "data-turbolinks-track" => true%>


def show
  @invoice_items = @invoice.accounts_receivables_items

  respond_to do |format|
    format.html { render :template => "invoices/show"}
    format.pdf  {render :pdf => "invoices/show",
                        :template => 'layouts/application.html', formats: :html, encoding: 'utf8', :show_as_html => params[:debug].present?}
  end
end

我明白了。这是我的网页(layout / application.html),但没有<%= yield %>内容

enter image description here

修改

enter image description here

1 个答案:

答案 0 :(得分:1)

因为您指定了:template作为您的布局文件,所以它会在没有视图的情况下呈现您的布局。

如何更像这样(注意模板和布局键):

render pdf: "invoice",
       layout: 'layouts/application.html',
       template: 'invoices/show',
       formats: :html,
       encoding: 'utf8',
       show_as_html: params[:debug].present?