Reputation: 1465
I'm having trouble with static assets (images and js and stylesheets) not being served on Heroku. Works fine in my local dev env.
Errors look like this:
2011-08-08T02:58:45+00:00 app[web.1]: Started GET "/stylesheets/reset.css" for 98.234.235.21 at 2011-08-07 19:58:45 -0700
2011-08-08T02:58:45+00:00 app[web.1]:
2011-08-08T02:58:45+00:00 app[web.1]: ActionController::RoutingError (No route matches "/stylesheets/reset.css"):
I'm using:
I've searched on google / stackoverflow and tried the following with no luck:
use ActionDispatch::Static, "#{Rails.root}/public"
to config.ruconfig.serve_static_assets = true
in staging.rbCan anyone suggest a fix? Should I be using Cedar instead of Bamboo? Should I be using something else instead of thin?
Thanks!
EDIT: js files are being served, but images and stylesheets are not. I checked that the paths in my links are consistent.
myapp.heroku.com/stylesheets/reset.css
- fails
myapp.heroku.com/javascripts/jquery.js
- succeeds
I also attempted to set the following: config.action_dispatch.x_sendfile_header = nil
.
This goes along with config.serve_static_assets = true
but noticed that Heroku forces these options no matter how you set them. i.e. it does the following during startup:
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
Upvotes: 2
Views: 3054
Reputation: 1465
The problem turned out to be that the asset files didn't get pushed to heroku (I had a git screwup, not a heroku issue).
Heroku support pointed this out when I contacted them. They promptly replied with a detailed answer, which also included the following comments:
Upvotes: 3
Reputation: 107718
I am not confident that Heroku is running in the staging
environment, I think it's running in the production
environment instead and this is why your settings are not being applied.
Upvotes: 0