How do you associate a css/sass stylesheet to a view in rails?
This is a really generic question, to which I haven't found a simple answer.
I'm dealing with messy legacy code that specifies st开发者_运维知识库yle several times for the same classes/views. I have .sass files in app/styles
, .css files in public/stylesheets
and public/css
I don't understand which stylesheets includes which, or if they ever do. How do you match stylesheets to a specific view in rails? How do you define hierarchy between style so ones can override others?
What's the rails default for matching styles to views? I don't see any stylesheet_link_tag
used in the app
The best way would be to put a named yield in your application layout:
<%= yield :head %>
Then use a content for block in your view:
<% content_for :head do %>
<%= stylesheet_link_tag :my_css -%>
<% end %>
精彩评论