Reputation: 3558
Asset filtered out and will not be served: add
Rails.application.config.assets.precompile += %w( home.css )
toconfig/initializers/assets.rb
and restart your server
I am trying to setup multiple layouts that hit different .css.scss and .js setups, one for the home page, and others for various sections of the application.
My home layout looks like:
doctype html
= render 'layouts/components/view_source_msg'
html
head
title
= browser_title(yield(:title))
= render 'layouts/components/meta'
= render 'layouts/components/favicons'
= stylesheet_link_tag 'home'
= csrf_meta_tags
body[class="#{build_body_class} loading"]
== yield
= render 'layouts/components/analytics'
= javascript_include_tag 'home'
javascript:
$(function(){
$(document).foundation();
view_#{controller.controller_name.downcase}.init();
});
The error states to setup an initializer assets.rb which I have setup as:
Rails.application.config.assets.precompile += %w( *.css.sass )
Rails.application.config.assets.precompile += %w( *.css.scss )
Rails.application.config.assets.precompile += %w( *.js )
Rails.application.config.assets.precompile += %w( *.js.coffee )
Rails.application.config.assets.precompile += %w( *.js.coffee.erb )
But this is not working... Can anyone point me in the right direction? Thank you
Update
I was able to get this working by...
Rails.application.config.assets.precompile += %w( home.css )
Rails.application.config.assets.precompile += %w( home.js )
But this seems a bit off. In my old rails applications the other methods would have worked just fine...
Upvotes: 4
Views: 3182
Reputation: 5120
Since Rails v4, the sprockets gem now handles the asset pipeline. It looks for stylesheet files inside the app/assets/stylesheets
and the vendor/assets/stylesheets
folders, so if you are putting home.css
in public/assets/stylesheets
or something, it's not going to look there. If you specifically tell rails to precompile any asset matching that name, like you did in your fix, it will do so and then output the compiled stylesheet and know to reference it, so that's why it works. However this is not the preferred convention. Ruby API for Coding Links to Assets
Upvotes: 1