I'm using Ruby 2.0.0-p247
and Rails 4.0.0
If I make a minimal Rails 4 site like this:
rails new minimal
cd minimal
rails generate controller home index
tee config/routes.rb <<EOF
Minimal::Application.routes.draw do
root 'home#index'
end
EOF
Then precompile the assets with
rake assets:precompile
It generates assets like:
I, [2013-09-04T17:05:36.992951 #3549] INFO -- : Writing /WORKINGDIR/minimal/public/assets/application-723d1be6cc741a3aabb1cec24276d681.js
I, [2013-09-04T17:05:37.052303 #3549] INFO -- : Writing /WORKINGDIR/minimal/public/assets/application-f1a14051f17824976271b9c0460232f0.css
But if I start the server in production mode, with
RAILS_ENV=production rails s
The generated URLs in the HTML don't point at the precompiled files:
<link data-turbolinks-track="true" href="/stylesheets/application.css" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/javascripts/application.js"></script>
I would expect, rather:
<link data-turbolinks-track="true" href="assets/application-f1a14051f17824976271b9c0460232f0.css" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/application-723d1be6cc741a3aabb1cec24276d681.js"></script>
The default config/environments/production.rb
settings say to use digests:
config.assets.digest = true
But it seems to be selectively ignored?
Am I missing something?
UPDATE:
I just tested this in Rails 4.2.3 and this appears to be fixed, however we need to hand a few more environment variables into the rails s
command to start in production mode:
SECRET_KEY_BASE=$(rake secret) RAILS_SERVE_STATIC_FILES=true RAILS_ENV=production rails s