rake assets:precompile
currently spits everything into my public/assets
directory when I was under the impression (after setting up S3) that it would push up to Amazon. I am utilizing asset_sync
as outlined here
Currently I have this in my application.rb
:
class Application < Rails::Application
config.assets.enabled = true
config.assets.digest = true
end
Then in my development.rb
I have:
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY_DEV']}.s3.amazonaws.com"
config.action_mailer.asset_host = "http://#{ENV['FOG_DIRECTORY_DEV']}.s3.amazonaws.com"
config.assets.initialize_on_precompile = false
What am I doing wrong here?
You must appreciate that asset_sync
is there to sync your assets (not replace them)
Asset Sync
The gem itself will let Rails publish your assets "locally" (to /public/assets
), and then it will essentially push them all to your S3 bucket, replicating them.
As described by the gem's documentation :
Synchronises Assets between Rails and S3.
Asset Sync is built to run with the new Rails Asset Pipeline feature introduced in Rails 3.1. After you run bundle exec rake assets:precompile your assets will be synchronised to your S3 bucket, optionally deleting unused files and only uploading the files it needs to.
--
Fix
In regards to your problem, I'm sure that by default, development assets are served dynamically - meaning that if you want to run them as static (precompiled), you'll have to tweak some of the settings which define this:
#config/environments/development.rb
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false #true
This should enable you to use the precompiled assets locally (in development), which will in turn allow you to use S3
Production serves static assets by default, meaning the most applicable way to test asset_sync
is literally by deploying to your production environment. However, you should be able to use the code above to get it to work in development, too
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.