0

I'm trying to setup a staging environment.

I copied the environments/production.rb to create environments/staging.rb.

I tested the staging environment locally and ran

RAILS_ENV=staging rake assets:clean assets:precompile
RAILS_ENV=staging rails s

Assets are properly generated in public/assets, and when I load a page, the links to the assets are correct (eg: /assets/application-e014056a81279320a97c71ed25eb46ab.css)

But the browser can't load them and if I try to open

http://localhost:3000/assets/application-e014056a81279320a97c71ed25eb46ab.css

I get a 404.

Now the strange thing is that it works in production, with:

RAILS_ENV=production rake assets:clean assets:precompile
RAILS_ENV=production rails s

For both environments/staging.rb and environments/production.rb, the config is

config.serve_static_assets = false

config.assets.compile = false

config.assets.digest = true

And in application.rb

Bundler.require(*Rails.groups(assets: %w(development test)))

Do you have any idea where to look ? What else could differentiate the staging environment from the production environment ?

Arnaud
  • 17,268
  • 9
  • 65
  • 83
  • 1
    You mentioned the links to the assets are correct - so just to make double sure - the names of the files in the links exactly match the names of the generated files in staging? – jefflunt Jun 20 '14 at 21:03
  • @jefflunt Yes. I just found the solution though! Thanks for reading and trying to help. – Arnaud Jun 20 '14 at 21:07

1 Answers1

3

So, I had forgotten the role of the 'rails_12factor' gem.

I updated my Gemfile to

gem 'rails_12factor', group: [:staging, :production]

And everything works now.

Arnaud
  • 17,268
  • 9
  • 65
  • 83