Rails asset pipeline on staging: correct fingerprint but 404ing Rails asset pipeline on staging: correct fingerprint but 404ing ruby-on-rails ruby-on-rails

Rails asset pipeline on staging: correct fingerprint but 404ing


Despite suggestions in other answers

config.assets.compile = true

...is a workaround, not a solution. This option enables Rails to fall back to on-the-fly compilation of assets that can't be found in public/assets. It may 'solve' your problem in staging but having Rails compile assets at run-time is not exactly optimal in production.

I remember in the early months of working with the new asset pipeline in Rails 3.1.x that I had problems with both compression and generation of digests that I only really solved in later versions. I'd suggest trying out

config.assets.compress = falseconfig.assets.digest = false

both individually and together. And/or upgrade to later versions of Rails or the asset pipeline gems.


If you are certain the assets are being compiled and exist in the public directory, could it be your web server settings? On production/staging environments the assets shouldn't hit the rails app and be served directly from the web server. Heres an example apache config snippet:

   <LocationMatch "^/assets/.*$">      Header unset ETag      FileETag None      # RFC says only cache for 1 year      ExpiresActive On      ExpiresDefault "access plus 1 year"      SetEnv no-gzip      RewriteEngine on      # Make sure the browser supports gzip encoding before we send it      RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b      RewriteCond %{REQUEST_FILENAME}.gz -s      RewriteRule ^(.+) $1.gz [L]   </LocationMatch>   <FilesMatch \.css\.gz$>      ForceType text/css      Header set Content-Encoding gzip   </FilesMatch>   <FilesMatch \.js\.gz$>      ForceType text/javascript      Header set Content-Encoding gzip   </FilesMatch>


config.assets.compile = false

Should be:

config.assets.compile = true

Also, make sure clear your cache:

bundle exec rake tmp:cache:clear

and restart the server.