问题
I've been pulling my hair out for this one. I've always had a bad relationship with the asset-pipeline, it is always giving me trouble.. And today again..
When I try and compile my assets locally, everything is fine:
$ RAILS_ENV=production rake assets:precompile --trace
But when I deploy with Capistrano which does:
cd /var/www/xxx/releases/20140717164232 && ( RAILS_ENV=production bundle exec rake assets:precompile )
It crashes with the following error:
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
(in /var/www/xxx/releases/20140717164232/app/assets/stylesheets/application-sign-in.css)
/var/www/xxx/shared/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/sass_functions.rb:63:in `sprockets_context'
I seriously do not know how to debug this.. Locally I can't reproduce it and on my server the error is just not pointing me anywhere..
I've searched for the error and tried a couple things but nothing helped. Some say the error is going away by updating.. Or by adding the sprockets gem before the sass-rails gem.
My project is setup like the following; A regular rails 4 app with a gem containing assets representing a template. I use the following line to make sure everything is compiled:
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.css *.js *.eot *.woff *.ttf *.svg)
Anyone that knows how to solve this, or how to debug it?
EDIT
Removing all asset-url()
helper seems to work.. But again, no clue why..
回答1:
I had the samme issue and it turned out to be a css file containing asset-url
that didnt have the .scss
extension. Weirdly I could compile the assets locally but not on the server.
回答2:
the problem is because of .css extension instead of .scss. I have changed it on .scss and it worked.
回答3:
Heroku has a post about this. Precompile it locally and add all those files especially /public/assets/manifest.yml
. Heroku should ignore pre compilation and proceed.
来源:https://stackoverflow.com/questions/24809432/asset-compiling-crashing-on-server-environment-with-nomethoderror-undefined-m