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.