Avoid rendering a seperate layout's CSS file in rails 4 (conflicting stylesheets)
layout, ruby-on-rails, ruby-on-rails-4
Solution
You've probably got a line up the top of `application.css.scss`, in the comments, like this:
*= require_tree .
That is requiring ALL the files in your stylesheets directory. You'll need to remove it, and include just the ones you want, one by one.
Problem
I have a 'welcome' controller. I want to use a separate layout for this controller called welcome.html.erb which I want to use ONLY welcome.css.scss - I got this working. Now I have a 'pages' controller that uses the default application layout. However, this application layout, which uses application.css.scss, also renders my OTHER layout's css (welcome.css.scss). This results in all of my pages actions looking all screwed up because my styles for the other layout are being applied. welcome.html.erb (layout) css declaration ``` <%= stylesheet_link_tag 'welcome', media: 'all', 'data-turbolinks' => true %> ``` My application.html.erb (layout) is still the default set up. To summarize, when I load the pages controller I specify my pages layout, which in turn just uses the welcome.css.scss - all is good. I click on a link which brings me to the pages controller and BAM ... it loads all of my css files and the welcome.css.scss conflicts with the application.css.scss. Some possible solutions: - Just add an id to the welcome.html.erb body tag to wrap all of its styles into its own little selector and add it to the application.css.scss (seems hackish) - Possibly change the little declarations at the top of the application.css.scss? I have been researching and experimenting for a while and I have resorted to S.O. Thanks for any help.