title: Rails 404 error for Stylesheet or JavaScript files
body: <p>Rails can't load (404 error) CSS &amp; JS files on production but has no problem loading them in development.</p>
  
  <p>I'm using Capistrano for deployment and running Rails 3. My path on development is <strong>/www/myapp</strong> but my path on production is <strong>/www/myapp/current</strong>.</p>
  
  <p>The application itself seems to work fine, so the issue seems to be isolated to CSS/JS files.</p>
  
  <p>I tried setting the <strong>RAILS_ROOT</strong> variable to <strong>/www/myapp/current</strong> in <strong>environments/production.rb</strong> but it did not make any difference, the files still don't load.</p>
  
  <p>Here's the full stack from the production log:</p>
  
  <pre><code>Started GET "/stylesheets/scaffold.css?1280867531" for 98.173.61.21 at 2010-08-04 17:04:05 -0700
  
  ActionController::RoutingError (No route matches "/stylesheets/scaffold.css"):
  /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/show_exceptions.rb:55:in `call'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/railties-3.0.0.beta4/lib/rails/rack/logger.rb:14:in `call'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/rack-1.1.0/lib/rack/runtime.rb:17:in `call'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/rack-1.1.0/lib/rack/lock.rb:11:in `block in call'
    &lt;internal:prelude&gt;:10:in `synchronize'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/railties-3.0.0.beta4/lib/rails/application.rb:145:in `call'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/railties-3.0.0.beta4/lib/rails/application.rb:81:in `method_missing'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:642:in `process_client'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:715:in `block in worker_loop'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:713:in `each'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:713:in `worker_loop'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:604:in `block (2 levels) in spawn_missing_workers'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:601:in `fork'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:601:in `block in spawn_missing_workers'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:597:in `each'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:597:in `spawn_missing_workers'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:611:in `maintain_worker_count'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:270:in `start'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/lib/unicorn.rb:29:in `run'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/gems/unicorn-1.1.2/bin/unicorn:123:in `&lt;top (required)&gt;'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/bin/unicorn:19:in `load'
    /usr/local/rvm/gems/ruby-1.9.2-rc2/bin/unicorn:19:in `&lt;main&gt;'
  </code></pre>