How do I use CSS with RoR? When I link externally, I\'m never able to see the files. I cp\'d the .css file to every folder I could think of...views, controller, template, an
The original post might have been true back in 2009, but now it is actually incorrect now, and no linking is even required for the stylesheet as I see mentioned in some of the other responses. Rails will now do this for you by default.
You can test this with a path in your browser like testserverpath:3000/assets/filename_to_test.css?body=1
Use the rails style sheet tag to link your main.css like this
<%= stylesheet_link_tag "main" %>
Go to
config/initializers/assets.rb
Once inside the assets.rb
add the following code snippet just below the Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.precompile += %w( main.css )
Restart your server.