Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
457 views
in Technique[技术] by (71.8m points)

ruby on rails 4 - Asset filtered out and will not be served: add `config.assets.precompile

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

ActionView::Template::Error: Asset filtered out and will not be served: add `config.assets.precompile += %w( my_js )` to `config/application.rb` and restart your server
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Responding to urging from Heroku, the Rails maintainers have merged sanity checks from the sprockets_better_errors gem into Rails 4.1. See https://github.com/rails/sprockets-rails/pull/84

The intent is to reveal asset pipeline errors that you would see in production when you run the app in development mode.

You probably are using a javascript_include_tag in an application layout instead of placing your JavaScript files in the app/assets/javascripts/ folder.

You could move your files to the app/assets/javascripts/ folder.

Alternatively, you'll need to update your config/application.rb file to include:

config.assets.precompile += %w( my_js )

Note that the filename should not include the .js file extension.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...