Alex Blakemore
Alex Blakemore

Reputation: 11896

RoutingError raised when using precompiled assets in production environment

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.

Upvotes: 3

Views: 1028

Answers (1)

Alex Blakemore
Alex Blakemore

Reputation: 11896

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)

Upvotes: 6

Related Questions