Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wicked_PDF templates is missing

I installed wicked PDF and modified my controller :

def show
  respond_to do |format|
    format.pdf do
      render :pdf => "file_name"
    end
    format.html
  end
end

Here is how i link to the pdf : compte_contrat_path(c,:format=>'pdf')

It works for html (without the format) but fail for PDF with the following error :

Template is missing

Missing template contrats/show with {:locale=>[:fr], :formats=>[:pdf], :handlers=>[:erb, :builder, :coffee, :arb]}. Searched in: * "/home/sylario/ruby/place_de_marche/app/views" * "/usr/local/rvm/gems/ruby-1.9.2-p136/gems/activeadmin-0.5.0/app/views" * "/usr/local/rvm/gems/ruby-1.9.2-p136/gems/kaminari-0.14.1/app/views" * "/usr/local/rvm/gems/ruby-1.9.2-p136/gems/devise-2.2.0/app/views"

What am I doing wrong?

like image 280
Syl Avatar asked Jul 09 '13 13:07

Syl


1 Answers

Thanks to henry I now know it was related to the format of the ERB. I have found a way to reuse my html.erb files :

First i do the following in the controller

format.pdf do
    render  :pdf => "file.pdf", :template => 'contrats/show.html.erb'
end

Then when i use partials i call them like this :

render :partial => 'fullpath/toview.html.erb', :formats => [:html], :locals => { :mylocal=>@something }
like image 152
Syl Avatar answered Sep 17 '22 03:09

Syl