0

Recently upgraded to Rails 4.0.2 from 3.2 on Heroku. I'm noticing that maybe every other push my stylesheet_link_tag and javascript_include_tag tags point to my development path (i.e. /assets/admin.css) instead of my production/precompiled @ fingerprinted path such as /assets/admin-a334a2cf57ed6ffc29f7f7a1af35f380.css

here are the relevant setting from production.rb:

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true

Because I am on Heroku I have config.assets.initialize_on_precompile = false in application.rb. So I always run bundle exec rake assets:precompile before deploying if I have made any changes to asset files.

Here is my folder hierarchy:

app
 -assets
   -images
   -javascripts
   -stylesheets
     -themes
       dark.css
       blue.css
       etc...
     admin.css
     application.css
     jobboard.css

here is my application.config

config.assets.precompile += [
    'admin.css',
    'admin.js',
    'jobboard.js',
    'jobboard.css',
    'themes/dark.css',
    'themes/blue.css',
    'themes/green.css',
    'themes/plain.css',
    'themes/seafoam-flat.css',
    'themes/fire-flat.css'
  ]

But for some reason I get this inconsistent behavior in production. All files precompile. But sometimes the admin.css file is not referenced w/ the fingerprint, same for the css files under /themes. Any clue as to why this might happen?

cman77
  • 1,753
  • 1
  • 22
  • 48

1 Answers1

0

If there's a missing precompile file maybe you should add them in config/application.rb

config.assets.precompile += %w( admin.css )

and then

RAILS_ENV=production bundle exec rake assets:precompile

You can check in the manifest ( public/assets ) for missing file or to see the fingerprint.

coding addicted
  • 3,422
  • 2
  • 36
  • 47
  • Thanks. I have all my files listed in config/application.rb. Nothing is reported as missing. – cman77 Jan 13 '14 at 21:07
  • Thanks. This issue isn't really that the are missing. It's that sometime the correct/precompiled version is referenced, and sometime the development version is referenced. When the dev version is referenced in production - it's not there and thus no css is rendered. – cman77 Jan 13 '14 at 21:13
  • Is it a random file or always the same that is involved? – coding addicted Jan 13 '14 at 21:17
  • it's always the same few files - but it is randomly happening. – cman77 Jan 13 '14 at 21:22
  • This post (http://stackoverflow.com/questions/14697604/rails-assets-precompile-just-not-working?rq=1) suggests that heroku usually compiles assets directly. Maybe this make a conflict with your locally compiled assets? – coding addicted Jan 13 '14 at 21:33