Excluding rails css files from views
Sorry for the odd question but this is one that makes me want to bust a head. Theres a file in my rails app called project.css and I don't know if it came with the rails application built in.
One of the programmers I'm working with decided to fill it with generic styles which have effected everything that wasn't assigned its own style by id or class.
EG he writes
td
{
position:absolute;
top:20px;
font-family:Wingdings;
}
So that all his style are replicated across the entire site including my pages.
rather than going through all my pages and creating styles for every element that I need to use, can I just explicit say in my pages to ignore this file?
EG <% stylesheet_ignore_tag %>
It seems to be including the stylesheet by default 开发者_如何学Goso the questions are:
1: Is the project.css part of rails. if not then I'd question why the hell its bleeding all over the site.
2: Can i get rid of it or tell my pages not to load it.
3: If theres no ignore feature for stylesheets has anyone got any ideas as to how to fix it without going through each page and making styles for each element he screwed up?
Think i figured out what happened. He included this monstrosity of a css file in the application.html.erb file. This is a header that's shared across all the site. This way it seems to have effected all the individual pages being loaded aswell.
You should consider using content_for for that css file. This way you can remove it from the layout, put a <%= yield :specific_css %>
instead and use content_for in the views that use that css this way:
<%= content_for :specific_css %>
<%= stylesheet_link_tag 'your_file.css' %>
<% end %>
Sounds like it's being loaded in the general layout file.
If it's really not being used except to make life painful for you... why not just delete it from your repository? :)
Better yet - go ask the guy what he did that for and whether you can work something else out.
精彩评论