3

Trying to test deploy a simple Rails 3.1 app in production mode, using the asset pipeline, after precompiling the assets. Using JRuby and WEBrick 1.3.1 for now; the plan is to deploy next on JBoss.

Everything works fine running in development environment, but in production it raises RoutingError when the client requests any precompiled asset.

The Rails server log looks like:

Started GET "/assets/application-a04f15ca8cb6078896dbdc22266757d9.css" for 127.0.0.1 at 2012-02-06 18:19:04 -0500

ActionController::RoutingError (No route matches [GET] "/assets/application-a04f15ca8cb6078896dbdc22266757d9.css)

The precompiled assets are in the applications public/assets directory.

Should I expect WEBrick to be able to handle /public/assets? or can I only test that when deployed on Apache or such?

Any help would be greatly appreciated.

Alex Blakemore
  • 11,301
  • 2
  • 26
  • 49
  • what asset settings do you have in your production environment? there is a lot to be configured: http://guides.rubyonrails.org/asset_pipeline.html#in-production – phoet Feb 07 '12 at 20:25
  • In production.rb: config.assets.compress=true;config.assets.compile=false;config.assets.digest=true; – Alex Blakemore Feb 08 '12 at 00:40

1 Answers1

6

The answer is at No route matches [GET] /assets

It makes sense. Rails in production mode doesn't serve static assets by default, leaving that to the deployment server. You can configure rails to serve static assets by setting config.serve_static_assets to true (though you probably get better performance leaving it as false)

Community
  • 1
  • 1
Alex Blakemore
  • 11,301
  • 2
  • 26
  • 49
  • 1
    it's not realy about performance, it's more that your need to 'warmup' you application, cause otherwise the first user hitting the app will trigger the compilation step, which might take some seconds/minutes depending on the amount of assets you have. – phoet Feb 08 '12 at 07:13
  • I'd precompile assets for production in either case. My speculation about performance was that it would be faster to skip the wholes Rails middleware stack when deploying static assets from public, so that's probably why its left to Apache by default. – Alex Blakemore Feb 08 '12 at 17:55