Where should i create a folder to house my CSS files within my rails app directory??
stylesheet_link_tag
takes arrays of stylesheets as well as a string.
For example:
= stylesheet_link_tag %w[ screen print ]
There are some great examples of using the stylesheet_link_tag
helper at APIDock.
For Rails 3.1+ apps, you should use the asset pipeline. Place stylesheets in app/assets/stylesheets/
if they are specific to your application. You can also put them at vendor/assets/stylesheets/
if they are external (say if they are stylesheets for a javascript plugin.)
After that, you will include stylesheets using the app/assets/stylesheets/application.css
if it is included in your layout file (see other answers for how to do this.)
for Rails 2.x : public/stylesheets
/app
is for programmatic content (your models, views, controllers, layouts, partials, etc). /public
is for your static content (html, images, stylesheets, javascripts, etc)
so the correct place for your stylesheets would be /public/stylesheets
. If you follow this convention, you can use the stylesheet_link_tag
helper, so if you put style.css
into /public/stylesheets
, then
<%= stylesheet_link_tag "style" %>
will get rendered as
<link href="/stylesheets/style.css?1232285206" media="screen" rel="stylesheet" type="text/css" />
For Rails 4:
1) Add your .css
file in app/assets/stylesheets
2) In your view file <%= stylesheet_link_tag 'uploaded_file_name' %>
put it in public/stylesheets
then use
<%= stylesheet_link_tag "style_sheet_file_name" %>
in your