S3 resource issue

In production I am using Heroku and dynamic assets on S3. It works fine. Now I am trying to send my static assets to S3. I followed this tutorial https://devcenter.heroku.com/articles/cdn-asset-host-rails31

I added the asset_sync resource, I configured my heroic ENVs, my config / production.rb and ran heroku run rake assets:precompile

Everything seems to be fine:

    Using: Directory Search of / app / public / assets
    Uploading: assets / application.js.gz
    Uploading: assets / application.css
    Uploading: assets / application-8977252f192f3e36dbd6b5142de920e3.css.gz
    Uploading: assets / eurof35-webfont-4ea19cda003d589e688cedcf9f79ddd6.eot
    Uploading: assets / application.css.gz
    Uploading: assets / application-8977252f192f3e36dbd6b5142de920e3.css
    Uploading: assets / application-a904f1bc7724b6f68e1f8d38d03a093e.js.gz
    Uploading: assets / application-a904f1bc7724b6f68e1f8d38d03a093e.js
    Uploading: assets / application.js
    AssetSync: Done.

However, when I load my site, there are no CSS or JS files. When I check the code, <link href="http://s3.amazonaws.com/annoncestest/assets/application-85cc4376a5de3b224db7c0548a44e7cb.css" media="all" rel="stylesheet" type="text/css" />


As you can see the CSS application that is being called is not the same as my S3 box.

Do you have any ideas?

EDIT: However, it works great for the application.js file, it takes good files. But not for css files (application.css and admin.css). I tried with CloudFront and the result is the same.


source to share

2 answers

To close the ticket, I finally found a solution thanks to Geroku's help. The solution is in this other ticket Why Heroku doesn't use good manifest.yml

Hope this helps!



You are using Rails 3.2, so much easier now. Take out the asset_sync gem. Go to Amazon and find the CloudFront section (instead of S3). This is their front end CDN. You may have used it to use your S3 bucket before.

With Rails 3.2, all you need to do is set up CloudFront to use "Origin". With source, you specify the location of your app instead of the bucket. When a user requests a file from the CDN, the CDN goes to your application to get the file and add it to the CDN cache. Because Rails Assets uses a unique filename, you will always have the most updated file.

Place the CloudFront location in your rails app as a source for assets. Then expand and let the hero compile your resources.

Place the following in your production.rb

  # Setup amazon CDN
  config.action_controller.asset_host = "xxxxxxxxxxxxx.cloudfront.net"




All Articles