`undefined method` find_asset 'for nil: NilClass`

I use 'rails', '4.2.5' and the wicked_pdf gem to create and download the PDF, but on Heroku, this does not include css using the wicked_pdf_stylesheet_link_tag tag.

Heroku error log:

 ActionView::Template::Error (undefined method 'find_asset' for nil:NilClass) 

Did I miss any configuration here?

+5
source share
2 answers

For work in the environment of development and production do not use

 Rails.application.assets.find_asset(logical_file_path).to_s 

for sprockets-rails version 3.0.0 , but use this (compass rails required):

 CompassRails.sprockets.find_asset(logical_file_path).to_s 

If you are not using garm compass-rails, you can get the asset with:

 (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(logical_file_path).to_s 
+26
source

A simple Google search showed that this error was published in the official replica of wicked_pdf in December.

Setting assets.compile = true , as recommended in the release, will fix it. This change is not required with sprocket-rails ! = 3.0.0

+4
source

Source: https://habr.com/ru/post/1242473/


All Articles