views:

468

answers:

3

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, and nothing seems to work.

What do I need to do to enable external CSS files with a rails application? I'm new to rails, so forgive me if this is basic.

Solution:

Put the CSS files in public/stylesheets and then use: <%= stylesheet_link_tag "filename" %>

A: 

Have you tried putting it in your public folder? Whenever I have images or the like that I need to reference externally, I put it all there.

Chris Bunch
+6  A: 

Put the CSS files in public/stylesheets and then use:

<%= stylesheet_link_tag "filename" %>

to link to the stylesheet in your layouts or erb files in your views.

Similarly you put images in public/images and javascript files in public/javascripts.

Kyle Boon
+1  A: 

To add to the above, the most obvious place to add stylesheet_link_tag is in your global application layout - application.html.erb.

Raphomet