Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`undefined method `find_asset' for nil:NilClass`

I am using 'rails', '4.2.5' and wicked_pdf gem for generating and downloading PDF, but on Heroku, it's not including css using 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?

like image 471
RockStar Avatar asked Feb 07 '16 09:02

RockStar


1 Answers

To get it work for development and production environment don't use

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

for sprockets-rails version > 3.0.0 but use this (requires gem compass-rails):

CompassRails.sprockets.find_asset(logical_file_path).to_s

If you don't use gem compass-rails you can get the asset with:

(Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(logical_file_path).to_s
like image 128
phlegx Avatar answered Oct 16 '22 22:10

phlegx