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:
- Ruby 1.9.2
- Rails 3.0.7
- Heroku with bamboo-mri-1.9.2 and thin webserver. (I followed default basic setup instructions on heroku.com)
I've searched on google / stackoverflow and tried the following with no luck:
- remove config.ru
- add
use ActionDispatch::Static, "#{Rails.root}/public"
to config.ru - set
config.serve_static_assets = true
in staging.rb
Can 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