I use Rails 3.2.2 on Heroku with CDN (CloudFront) to host assets.
I try the Heroku tutorial (https://devcenter.heroku.com/articles/cdn-asset-host-rails31) with asset_sync gem.
There is no problem with the assets:precompile, all my assets are hosted on my S3 bucket.
-->heroku run bundle exec rake assets:precompile
Running bundle exec rake assets:precompile attached to terminal... up, run.1
AssetSync: using default configuration from built-in initializer
AssetSync: Syncing.
Using: Manifest /app/public/assets/manifest.yml
Uploading: assets/facebook_64-8cdc90984860efef829203e1e01aab10.png
Uploading: assets/google_64-11634a6b4a219799449e7a7157f73387.png
Uploading: assets/twitter_64-657ee379209d0bb998440421b499a6a2.png
Uploading: assets/application-699d029330a2d095a9b59006a63a7b01.js
Uploading: assets/application-2060c0efc074ae11265455479abfb6ff.css
Uploading: assets/back_office-ccfdd79c9b296176087815c95607f540.css
AssetSync: Done.
The problem is that Heroku tries to access to a bad CSS files :
<link href="http://s3.amazonaws.com/annoncestest/assets/application-85cc4376a5de3b224db7c0548a44e7cb.css" media="all" rel="stylesheet" type="text/css" />
As you can see the MD5 for application CSS is not the same.
However there is no problem with JS files or other assets which are not CSS files.
On my bucket the manifest.yml refer to the good file application-2060c0efc074ae11265455479abfb6ff.css
but Heroku always tries to access to application-85cc4376a5de3b224db7c0548a44e7cb.css
I tried to set the manifest path in my production.rb with :
config.assets.manifest = "http://myapp.cloudfront.net/assets"
or
config.assets.manifest = "http://myapp.cloudfront.net/assets/manifest.yml"
Everytime css files are bad.
I have no idea what’s the problem. Any idea?
I solve the problem thanks to heroku support.
First, my deployment didn’t running well because I had the famous problem during rake assets:precompile
To prevent this you need to set
initialize_on_precompileto false in your config/application.rb (not in your config/environments/production.rb) :After that when you deploy the precompilation seems to work but there is a problem with asset_sync which not find your ENV variables (FOG_DIRECTORY and FOG_PROVIDER)
To solve this you need to install a heroku labs with these two commands:
And you deploy again on heroku and (theoricaly) it should work fine! (it works for me!)
I hope this is help somebody in the future!