1

"\nrequest.variant: #{request.variant.inspect}"

    raise ActionController::UnknownFormat, message
  elsif interactive_browser_request?
    message = "#{self.class.name}\##{action_name} is missing a template " \
      "for this request format and variant.\n\n" \

我的控制器

respond_to do |format|
  format.html
  format.pdf do
    pdf = Prawn::Document.new
    params[:id] = @ids
    @opcionales = Opcionale.where("id= ?", @ids)
    ...
    send_data pdf.render, filename: "Reporte_#{@opcionales}.pdf",
                        type: "application/pdf",
                        disposition: "inline"

  end
end

我的路线

获取“报告/选项”

获取 'reporte/opcionales/:id', 到: "reporte#opcionales", :defaults => { :format => 'pdf' }

在我看来

{<%= link_to "通用 PDF", '/reporte/opcionales/'+(opcionales.id.to_s)+'.pdf' %>}

4

1 回答 1

1

转到config/intializers/mime_types.rb并添加Mime::Type.register "application/pdf", :pdf然后安装 gem 响应程序

于 2018-02-01T07:12:33.180 回答