Where should i create a folder to house my CSS files within my rails app directory??
so then how do you link to this stylesheet??
zPesk
2009-06-29 15:24:10
either <%= stylesheet_link_tag 'file' %> or use a regular link to the path /stylesheets/file.css .
Ben Hughes
2009-06-29 15:26:13
If you had a stylesheet named foo.css, you would put this in the head section of whatever view needed it. <%= stylesheet_link_tag "foo" %>
Joel Meador
2009-06-29 15:29:30
+2
A:
put it in public/stylesheets
then use
<%= stylesheet_link_tag "style_sheet_file_name" %>
in your
Jason Miesionczek
2009-06-29 15:27:58
+2
A:
/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 stylesheetlink_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" />
Matt Briggs
2009-06-29 15:29:42
A:
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.
James Conroy-Finn
2009-06-29 22:50:42