I am using the assets pipeline (in Rails 3.1.3) and am kind of struggling to make it work in production.
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.
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 ?
Richard Hulse answers pointed me to the right direction. What happens is really subtle..
The answer to my question is Rails 3.1 assets has no fingerprint in production.
Basically, my project use mongoid instead of ActiveRecord. According to Mongoid documentation about configuration, the application.rb
file can be modified to not include ActiveRecord
which means removing:
require railties/all
And replacing it with:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
# require "sprockets/railtie" # Uncomment this line for Rails 3.1+
I was so used to doing this manipulation with rails 3.0.x that I did not pay attention to the comment related to Rails 3.1
My problem was that I was not requiring sprockets !
Thank you all for your help !