I have a controller action that responds to html and pdf format, for example:
def detail @record = Model.find(params[:id]) respond_to do |format| format.html
but when I receive the file, it comes with the name: 1.pdf 2.pdf depending on params[:id] how to set the file name to myfile.pdf
- UPDATE -
An example of my detail.pdf.prawn file
pdf.font "Helvetica" pdf.image open("http://localhost:3000/images/myImage.png"),:position => :left,:width=>100 pdf.text "some text" pdf.table(someData,:cell_style => { :border_width => 0.1,:border_color=> 'C1C1C1' }) do |table| table.row(0).style :background_color => 'D3D3D3' table.column(0..1).style(:align => :left) table.column(2..4).style(:align => :center) table.column(0).width = 100 table.column(1).width = 250 table.column(3..4).width = 68 table.row(2).column(0..2).borders = [] table.row(2).column(3).style(:font_style => :bold, :align => :right) end
pdf.font "Helvetica" pdf.image open("http://localhost:3000/images/myImage.png"),:position => :left,:width=>100 pdf.text "some text" pdf.table(someData,:cell_style => { :border_width => 0.1,:border_color=> 'C1C1C1' }) do |table| table.row(0).style :background_color => 'D3D3D3' table.column(0..1).style(:align => :left) table.column(2..4).style(:align => :center) table.column(0).width = 100 table.column(1).width = 250 table.column(3..4).width = 68 table.row(2).column(0..2).borders = [] table.row(2).column(3).style(:font_style => :bold, :align => :right) end
and format.pdf { render :layout => false } in the controller displays a pdf file with instructions on detail.pdf.prawn
source share