Asset filtered out and will not be served: add
Rails.application.config.assets.precompile += %w( login.js )
toconfig/initializers/assets.rb
and restart your server
I ge the above error when i try to run my application.
<% content_for :javascripts do %>
<%= javascript_include_tag 'login' %>
<% end %>
I have placed all my js files in assets/javascripts
, but still i get the above error.
I am doing something similar, but I've added my additional assets in Production.rb
You must include all js/css files that you include with
#javascript_include_tag
and#stylesheet_link_tag
methods inRails.application.config.assets.precompile
array. Check outconfig/initializers/assets.rb
(create if it does not exist). That's how it should look:Restart Rails server after editing.
By the way it is self-evident from error's text.
Check out Rails Assets Pipeline documentation for details: http://guides.rubyonrails.org/asset_pipeline.html .
As an alternative solution, you can also comment out this line on
development.rb
:config.assets.raise_runtime_errors
or set it to
false
This will disable sprockets runtime errors (the "Asset filtered out and will not be served" yada yada error) in development.
Keep in mind that by doing this, you can mask production errors for assets: eg. some assets will be served in development but not in production. (see this)
Use it if you know what you're doing :)
hth