Take the 2-minute tour ×

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.


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

share|improve this question
add comment

6 Answers

up vote 21 down vote accepted

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

<%= stylesheet_link_tag "filename" %>



share|improve this answer
there is no "public/stylesheets" where can I add my file? –  riship89 Mar 10 '12 at 3:48
Then you can create it add the public folder in the same directory as your app folder. Then add a stylesheets folder within the public folder. –  PJT May 1 '12 at 13:55
add comment

In the latest version of rails, you can do the following...

  2. Add the stylesheet link <%= stylesheet_link_tag "filename" %> in your default layouts file (most likely application.html.erb)


share|improve this answer
add comment




read more here about the asset pipeline

share|improve this answer
add comment

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

share|improve this answer
add comment


share|improve this answer
add comment


  • Test your server with rails-root/scripts/rails server and you'll see the link is added by rails itself.


share|improve this answer
add comment

Your Answer


