Asset filtered out and will not be served: add `config.assets.precompile

前端 未结 5 782
死守一世寂寞
死守一世寂寞 2020-12-08 13:17

I just migrated my Application to rails 4.1.0 from 4.1.rc2. Started getting these errors for my JS files

ActionView::Template::Err         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 14:11

    If you have added something like stylesheet_link_tag params[:controller] to your application layout header, because you have separate JS applications on different controllers but with same basic layout, you will be quite annoyed with this. Quick way to get over this and continue work (but maybe not a final solution) with all assets precompiled is to add the following to the /config/initializers/assets.rb:

    Rails.application.config.assets.precompile += [/.*\.js/,/.*\.css/]
    

    Note that this is as it is even for .js.coffee and .css.scss, .js and .css are enough.

提交回复
热议问题