Wicked_pdf: undefined method `find_asset' for nil:NilClass in production with sprockets-rails 3.0.0

Created on 21 Dec 2015  路  8Comments  路  Source: mileszs/wicked_pdf

wicked_pdf_stylesheet_link_tag fails with NoMethodError: undefined method 'find_asset' for nil:NilClass in production with sprockets-rails 3.0.0

See here: https://github.com/rails/sprockets-rails/issues/237


Something like this probably can be used instead of Rails.application.assets.find_asset:

manifest = Rails.application.assets_manifest
path = File.join(manifest.dir, manifest.assets['file.css'])
File.read(path)
asset-helpers

Most helpful comment

@unixmonkey It seems to be the same issue described on the link provided by @Bonias, as turning assets.compile = true "fixes" it.

According to that link, by the way, sprockets team isn't very much willing to match the old behaviour any soon.

All 8 comments

I'm seeing the same thing with rails 4.2.5 and sprockets-rails 3.0.0.

And me. Same versions as leesmith.

I'm getting this same error on a Heroku instance. Any known versions where this doesn't happen?

@MaximilianoFelice Looks like any version of sprockets-rails less than 3.0 should work for now, but your issue may not be related. There's a number of reasons your asset might not be found.

@Bonias Would you be able to help test out that bit of code on a few different versions of Rails and send a PR?

@unixmonkey It seems to be the same issue described on the link provided by @Bonias, as turning assets.compile = true "fixes" it.

According to that link, by the way, sprockets team isn't very much willing to match the old behaviour any soon.

rails 4.2, seeing the same issue in prod.

+1

Rails 4.2.0
Sprockets-rails 3.0.0
Production environment

Did same thing as MaximilianoFelice

assets.compile = true and it got fixed.

Please read my solution here: http://stackoverflow.com/a/37820647/132235

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EdouardPan picture EdouardPan  路  6Comments

lisamburns picture lisamburns  路  3Comments

chaudard picture chaudard  路  5Comments

douglasep picture douglasep  路  4Comments

kovloq picture kovloq  路  4Comments