0
votes

I know prawn is working because I have a show action that if I add .pdf on to the end of it loads show.pdf.prawn. However, I have a form:

 <%= form_tag(:controller => "/holders", :action=> "generate", format: "pdf") do %>
      <%= label_tag(:count, "How Many Students?") %>
      <%= text_field_tag(:count) %>
      <%= hidden_field_tag :holder_id, value: @holder%>
      <%= submit_tag("Generate Course Lesson") %>
    <% end %>

That submits count to the the generate action.

Inside my generate action I have the following:

    def generate
        prawnto :filename => "print.pdf"
        respond_to do |format|
      format.html
      format.pdf { render :layout => false}
    end
  end

and my generate.pdf.prawn looks like:

pdf.text "HELLO WORLD"

When I submit the form I get the URL: http://localhost:3000/generate.pdf and Chrome tells me Failed to load PDF document with no other errors or information.

I noticed I am getting: Rendered holders/generate.pdf.erb in my dev logs which indicates its not even looking for the .prawn file.

What am I doing wrong?

1
did you fix this problem? I have the same issueinye
@inye It was for this project here: github.com/noahc/teacherjoy I'm sure I got it working some how, but you'll have to check the source code to see what I did.Noah Clark
thx @noah, the solution was use prawnto gem.inye

1 Answers

0
votes

Setup your action like this:

def generate
  respond_to do |format|
    format.html
    format.pdf { prawnto :filename => 'print.pdf' }
  end
end