Reputation: 383
I'm making my first website with rails. I'm a little confused with how rails does css files.
<link rel="stylesheet"...
" right in one of the views?Upvotes: 0
Views: 51
Reputation: 1065
So basically its been decided that its quicker to compile all the CSS for your whole site and then thats cached on the users browser than to serve every different pages CSS. So for each view, you put *= require viewname
or if you have require_tree .
in your application.css
then it will autoload everything in that directory. The splitting of each CSS file is just purely for ease of development.
If you want to have seperate for each page then put stylesheet_link_tag "style"
at the top of your view, and make sure it's not included in application.css
. You will also need to add it to your asset compiling through:
# config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( cssfile.scss )
Upvotes: 2