I am using the assets pipeline (in Rails 3.1.3) and am kind of struggling to make it work in production.
Situation
In my /app/assets/stylesheets
directory I have the following files:
application.css --> this is the default rails one
stylesheet.css --> This is my custom stylesheet
I spent a lot of time getting my stylesheet.css
included in the /public/assets/
directory in production (by running rake assets:precompile
) and I finally made it by adding the following line into in my application.rb
file:
config.assets.precompile += ['stylesheet.css']
I know have the right precompiled stylesheet.css
file in production.
My Problem
The problem I have is when using stylesheet_link_tag
with my stylesheet.css
file. It turns out:
<%= stylesheet_link_tag "stylesheet" %>
is resolved into <link href="/stylesheets/stylesheet.css" media="screen" rel="stylesheet" type="text/css">
in production I would expect the path to be resolved into /assets/stylesheet.css
just like it does in development.
What is even more surprising is that application.css
behaves perfectly even though <%= stylesheet_link_tag "application"%>
resolves into <link href="/stylesheets/stylesheet.css" media="screen" rel="stylesheet" type="text/css">
. What I don't understand is that the public/stylesheets/ directory does not exist in rails 3.1.
Any idea ?
<%= stylesheet_link_tag "/assets/stylesheet.css" %>
. It is not satisfying but it works ! – Unlive