我使用gem wicked_pdf并且它在开发中工作,但是现在我试图在生产中生成pdf并不起作用。
这是我的设置:
gemfile.rb
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
配置/初始化/ wicked_pdf.rb
if Rails.env.production?
WickedPdf.config = {
exe_path: "#{ENV['GEM_HOME']}/gems/wkhtmltopdf-binary-#{Gem.loaded_specs['wkhtmltopdf-binary'].version}/bin/wkhtmltopdf"
}
end
controlller / user_profile_controller.rb
respond_to do |format|
format.html
format.pdf do
render :pdf => "ficha",:template => "user_profile/ficha.html.erb",viewport_size: '1280x1024'
end
end
我已经在 user_profile / ficha.html.erb 中找到了我的html视图
config / initializers / mime_types.rb
Mime::Type.register "application/pdf", :pdf
这是日志错误
Error: PDF could not be generated!
Command Error: /usr/bin/env: ruby: Permission denied
):