Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Sprockets::Rails::Helper::AssetNotPrecompiled in development

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 ) to config/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.

like image 475
Sydney Avatar asked Feb 28 '16 13:02

Sydney


1 Answers

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 
like image 92
eben.english Avatar answered Sep 21 '22 10:09

eben.english