我使用'rails', '4.2.5'
和wicked_pdf
gem來生成和下載PDF,但在Heroku上,它不包括使用wicked_pdf_stylesheet_link_tag
標籤的css。`未定義的方法`find_asset'爲零:NilClass`
Heroku的錯誤日誌:
ActionView::Template::Error (undefined method 'find_asset' for nil:NilClass)
難道我錯過這裏的任何配置?
我使用'rails', '4.2.5'
和wicked_pdf
gem來生成和下載PDF,但在Heroku上,它不包括使用wicked_pdf_stylesheet_link_tag
標籤的css。`未定義的方法`find_asset'爲零:NilClass`
Heroku的錯誤日誌:
ActionView::Template::Error (undefined method 'find_asset' for nil:NilClass)
難道我錯過這裏的任何配置?
一個簡單的Google搜索,在12月透露這個錯誤was reported in the official wicked_pdf repo。
設置assets.compile = true
在問題中的建議將解決它。這種變化不應該是必要的sprocket-rails
!= 3.0.0
爲了得到它發展和生產環境中工作,不使用
Rails.application.assets.find_asset(logical_file_path).to_s
爲鏈輪護欄版本> 3.0.0但使用這個(需要gem 指南針導軌):
3210如果不使用寶石羅盤軌道你可以得到資產:
(Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(logical_file_path).to_s
如果你使用上面的語句來檢查資產是否存在,最後刪除小的to_s,因爲''nil.to_s = 「」= true'' – ToniTornado
謝謝,但我已經訪問過的鏈接。 :-) – RockStar
你做了更改並重新啓動應用程序? –
是的!它也起作用。 – RockStar