I am relatively new to Rails and I am trying to use the asset pipeline, SCSS, in the development environment. However, after I created the controller, the view, and the css.scss
file, I encounter the following error:
Sprockets::Rails::Helper::AssetNotPrecompiled
Here is the error message:
Asset was not declared to be precompiled in production. Add
Rails.application.config.assets.precompile += %w( public.css )
toconfig/initializers/assets.rb
and restart your server
I read that in development, the assets get compiled on the fly and there is no need to pre-compile. Why is there a pre-compile error? Did Rails think that I am in production instead of development?
Edited on 1 March 2016 ------
I just realized that adding files onto the config/initializers/assets.rb works. But is this the right way to do it? I have to add all the css/js/jpg files manually in the assets.rb for it to work. I felt that this somehow violate the DRY principle.
Neither of these worked for me (rails-5.0.7, sprockets-3.7.2, sprockets-rails-3.2.1):
config.assets.debug = false config.assets.unknown_asset_fallback = true
But this did:
config.assets.check_precompiled_asset = false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With