Take the 2-minute tour ×

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 at 2011-08-07 19:58:45 -0700
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?


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:

       Installing rails3_serve_static_assets... done
       Installing rails3_disable_x_sendfile... done
share|improve this question

2 Answers 2

up vote 3 down vote accepted

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:

  • Heroku gem is not required to run on Heroku
  • Specify postgres gem in Gemfile; use postgres locally for development in place of sqlite3
  • config.ru: Don't run the dispatcher directly, run the app container
  • dont set x_sendfile_header to nil as this is not properly supported on Rails 3 (this is a Rails 3.1 setting)
share|improve this answer

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.

share|improve this answer
Ryan, I configured it to run staging, and verified that my changes are being applied: heroku config --remote staging shows RACK_ENV => staging and RAILS_ENV => staging –  stupakov Aug 8 '11 at 6:33

Your Answer


