Gemfile
gem "wicked_pdf"
gem "wkhtmltopdf-binary"
the error:
RuntimeError in CarsController#show
Failed to execute:
/usr/bin/wkhtmltopdf --print-media-type -q - -
Error: PDF could not be generated!
Rails.root: /u/apps/zeepauto/autozeep_update
cars_controller
def show
@class_showcar = true
@class_admin = true
@car = Car.find(params[:id])
@search = Car.search(params[:search])
@cars_see_special = Car.where(:special => "1").order('rand()').limit(3)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @car }
format.pdf do
render :pdf => "#{@car.carname.name}",
:print_media_type => true
end
end
end
show.html.erb
<p class="show_links"><%= link_to url_for(request.params.merge(:format => :pdf)) do %>
<%= image_tag('/images/printversion.png', :alt => 'Download') %>
</p>
wicked_pdf.erb
# config/initializers/wicked_pdf.rb
WickedPdf.config = {
# :exe_path => '/var/lib/gems/1.8/bin/wkhtmltopdf'
:exe_path => '/usr/bin/wkhtmltopdf'
}
I had the same problem. The solution was to add wkhtmltopdf-binary
to the gem file and run bundle install
.
gem "wicked_pdf"
gem "wkhtmltopdf-binary"