我已經看到了一些密切的問題,但一直未能找到解決方案來解決我的問題。我正在使用Ruby 1.9.3和Rails 3.2.13。資產管道中的圖像未找到
我正在使用Prawn生成PDF,並且我出現了一個標誌。該徽標在開發環境中沒有問題,但在Heroku上的生產環境中失敗。
在我的控制器我有:
def generate_risk_pdf(risk)
Prawn::Document.new do
image "#{Rails.root}/app/assets/images/logo-print.png", :scale => 0.75 if Rails.env.development?
image "#{ActionController::Base.helpers.asset_path('logo-print.png')}", :scale => 0.75 if Rails.env.production?
move_down 2
formatted_text [{:text => Exercise Australia", :styles => [:bold], :size => 20}]
font_size 6
bounding_box([bounds.right - 150, bounds.bottom], :width => 240, :height => 20) do
text "Copyright: Exercise Australia, #{Date.today.year}"
end
end.render
end
Heroku的日誌具有
引發ArgumentError(/assets/logo-print-5b6da7bd4012d953bc1bc749cf934d91.png未找到): 應用程序/控制器/ single_entries_controller。 rb:309:in`block in generate_risk_pdf'
其中對應上面一行用Rails.env.product離子?
如果我將URL追加到/assets/logo-print-5b6da7bd4012d953bc1bc749cf934d91.png圖像文件存在。
如果我刪除該行,它的工作原理(減去徽標)。
請注意,這不僅是蝦的失敗,但即使當我試圖使用內置的圖像電子郵件。
請幫忙,我把我的頭髮撕掉!
添加:從公共工程服務 - 但它不是我的首選解決方案。
是,一個我嘗試過的(很多)事情。沒有運氣! – user2699369