0

I have been trying to figure out why my production config will still only display the "non digest" URLs. If I run RAILS_ENV=production rails s locally, the URL's work just fine. But as soon as I push to production, the URLs show up like this, instead of digest.

//s3.amazonaws.com/xxxx/stylesheets/application.css

Here is my production config:

  # Disable Rails's static asset server (Apache or nginx will already do this).
  config.serve_static_assets = false

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

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

  config.action_controller.asset_host = "//s3.amazonaws.com/xxxxx"
  config.assets.prefix = "/production/assets"

Am I missing a trigger for the URL's to point towards the compiled digest URLs?

Another question reference, same issue (just found it). Rails 4.0.3 generating incorrect asset paths with asset_sync

Community
  • 1
  • 1
Jonathan Reyes
  • 1,387
  • 1
  • 10
  • 23

1 Answers1

0

Hopefully this will help save my fellow programmer friends some head banging :D. I have answered this question on "digest_path & asset_digest_path not allowing digest URLs" but will repost it here so it will save you some clicks.

I was uploading the files to S3, I didn't realize that the manifest wasn't loaded by Rails. You can have all your production settings right (like above and in other threads), but if you don't have the manifest.json file readable by Rails, it will still generate /javascript/* (example) urls.

I was still having trouble with multi_json gem's latest version, so I downgraded it to 1.7.8 and it works fine.

gem 'multi_json', '1.7.8'

That's so it can read the manifest.json file which rake assets:precompile creates.

There is a debate on this sprockets thread https://github.com/rails/sprockets-rails/issues/107 on whether your manifest file should be in git or just on a deploy script, do what suits you best, just make sure it is findable in:

/public/assets/manifest.json 

or specifiy it yourself with

config.assets.manifest = '...'

That may or may not be depricated.

Cheers!

Community
  • 1
  • 1
Jonathan Reyes
  • 1,387
  • 1
  • 10
  • 23