The best solution I can find is http://icelab.com.au/articles/asset-pipeline-tips/. However it’s quite high level, so here’s a step by step instruction on how I accomplished the task.
First, add the asset_sync gem to your
Gemfile inside the
assets group, and bundle install it
/config/application.rb, append any custom js and/or css files to the precompile list
/config/environments/production.rb to add the
Run the following to generate the asset_sync initialis(z)er. Tweak the config as your wish.
Next up, add all necessary AWS credentials as ENV vars
One thing to notice is the
FOG_DIRECTORY value. It is the bucket name you created on S3. I was using
_ in the bucket name,
fog to be specific was complaining about the name. Updating the bucket names to use
. instead of
_ muted all the noises.
I also configured the above 3 ENV vars on Heroku, but I think only
FOG_DIRECTORY is required.
Now, precompiling assets locally by doing
The above will put all the compiled assets in
/public/assets. Now we need to make git happy.
First, stage and commit
/public/assets/manifest.yml. Then edit
.gitignore by adding
This will make git track the asset manifest, but ignore all the other compiled asset files (coz they are already uploaded to S3 as a post asset compilation step by asset_sync).
All good, all working… But wait a second … Now when developing locally, compiled assets from
/public/assets are all loaded … trouble !!!
At the moment, I’m doing what’s suggested