undefined method `environment' for nil:NilClass when importing Bootstrap into rails undefined method `environment' for nil:NilClass when importing Bootstrap into rails ruby-on-rails ruby-on-rails

undefined method `environment' for nil:NilClass when importing Bootstrap into rails


I also met that exact same error after I upgraded rails from 4.0.3 to 4.0.4.

To solve solve this problem, only add

gem "sass-rails", "~> 4.0.2"

to your Gemfile and then

bundle install

Finally restart rails server

Then enjoy your programming in rails 4.0.4


When upgrading to Rails 4.0.5 you need to temporarily lock your sprockets at 2.11.x:

gem 'sprockets', '<= 2.11.0'

Then

bundle install

The exact error I was getting was:

ActionView::Template::Error: undefined method `environment' for nil:NilClass

For more context:

https://github.com/rails/sass-rails/issues/191

https://github.com/sstephenson/sprockets/issues/537