0

I have the action my_pdfs and there I have followings:

def my_pdfs
   respond_to do |format|
      format.pdf { render :layout => false }
   end
end

In the views/mycontroller is the file my_pdfs.html.erb and my_pdfs.pdf.prawn. How can I display the generated PDF? I tried something like:

localhost:3000/controller/my_pdfs/my_pdfs.pdf, but this is a bad way...

mu is too short
  • 426,620
  • 70
  • 833
  • 800
user984621
  • 46,344
  • 73
  • 224
  • 412

1 Answers1

1

I hope this link will help you.

It already have a good solution by using send_data.

class MyController < ApplicationController  

  def my_action
    doc = PdfGenerator.new(some_params)
    doc.generate

    send_data doc.render, filename: 'preview only.pdf', type: 'application/pdf'
  end
Rafaiel
  • 302
  • 4
  • 12