Paul S.
Paul S.

Reputation: 4502

CSS in Rails 3.0

I'm using Rails 3.0. How I can include a CSS that I put in /public/stylesheets into a View file in /app/views/posts?

Upvotes: 2

Views: 163

Answers (2)

Prakash Murthy
Prakash Murthy

Reputation: 13077

Asset pipeline was introduced in Rails 3.1.

In the previous versions (including Rails 3.0.0), you can link to CSS files with stylesheet_link_tag.

<%= stylesheet_link_tag "main" %>

Including the above code in the view file includes public/stylesheets/main.css file.

More details at http://guides.rubyonrails.org/v3.0.0/layouts_and_rendering.html#linking-to-css-files-with-stylesheet_link_tag

Upvotes: 1

Agis
Agis

Reputation: 33666

You should put it in /public/assets/ (it's the convention) and then you can do this:

<%= stylesheet_link_tag "example" %>

Or you can put it inside public/assets/stylesheets/ and do:

<%= stylesheet_link_tag "stylesheets/example" %>

Upvotes: 0

Related Questions