0
votes

Missing template events/index, application/index with {:locale=>[:en], :formats=>[:pdf], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml]}. Searched in: * "c:/Put/Team/project/app/views" * "c:/Put/Team/project/vendor/bundle/ruby/2.0.0/gems/browserlog-0.0.2/app/views" * "c:/Put/Team/project/vendor/bundle/ruby/2.0.0/gems/devise-3.4.1/app/views"

Here is the error I encounter when I'm trying to create a pdf from the ruby application I have made. This error occurs when I put .pdf on the end of my URL.

This is the code I've implemented in my app controller file

def show
   @event = current_user.events.find(params[:id])
   respond_to do |format|
       format.html
       format.pdf do
           pdf.text = Prawn::Document.new
           pdf.text "Hello World"
           send_data pdf.render
       end
   end  
 end
2
Try putting either filename: 'somefile.pdf' or disposition: 'inline' as option to send_data - katafrakt
@katafrakt I've tried that - Sprout

2 Answers

0
votes

It wants to render a template in your views, so my guess it's not recognizing your PDF render statement. It is odd that the pointer is to events/index while you're saying the source is the show method.

Try referring to this StackOverflow thread: How to render format in pdf in rails

0
votes

Make sure you name your view to "show.pdf".