[英]Rails 4 with asset_sync
Has anyone got the asset_sync gem to work with Rails 4? 有没有人让asset_sync gem与Rails 4一起使用? I have never had a problem with it with Rails 3, but i cannot precompile my assets to my S3 bucket anymore, what happens is everything is just compiled into my public folder.
我从未在Rails 3上遇到过任何问题,但是我无法将我的资产预编译到我的S3存储桶中,发生的事情是所有内容都被编译到了我的公用文件夹中。
Could anyone offer advice on resources to look at or summarise the key differences between Rails 3 and 4 that would cause this to fail. 谁能提供有关资源的建议,以查看或总结Rails 3和Rails 4之间的主要差异,否则可能会导致失败。 Some examples of configuration used would be helpful from those who have got it working.
某些使用配置的示例会对那些起作用的人员有所帮助。 I am at a loss on how to start debugging this
我对如何开始调试这个不知所措
Any advice and help appreciated 任何建议和帮助表示赞赏
Thanks 谢谢
EDIT 编辑
Current config 当前配置
asset_sync.rb # Within Initializer
asset_sync.rb #在初始化器中
if defined?(AssetSync)
AssetSync.configure do |config|
config.fog_provider = ENV['FOG_PROVIDER']
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
config.fog_directory = ENV['FOG_DIRECTORY']
config.fog_region = ENV['FOG_REGION']
config.existing_remote_files = "delete"
config.gzip_compression = true
config.manifest = true
config.custom_headers = { '.*' => { cache_control: 'max-age=315576000', expires: 1.year.from_now.httpdate } }
end
end
Production.rb Production.rb
YmcaView::Application.configure do
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.assets.version = '1.0'
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
end
Output when running rake assets:precompile RAILS_ENV=production 运行rake资产时的输出:precompile RAILS_ENV = production
I, [2014-03-04T13:04:41.176230 #6085] INFO -- : Writing /home/richardlewis/Rails/ymca_view/public/assets/760x380_10-477c3cdc939905d6b32f9997e7f93072.jpg
I, [2014-03-04T13:04:41.177963 #6085] INFO -- : Writing /home/richardlewis/Rails/ymca_view/public/assets/aboutus-d9ad504fcd86071255015d24780caef8.jpg
I, [2014-03-04T13:04:45.018794 #6085] INFO -- : Writing /home/richardlewis/Rails/ymca_view/public/assets/application-90d317f561a8b0e84124ce7bb872f867.js
I, [2014-03-04T13:04:46.666640 #6085] INFO -- : Writing /home/richardlewis/Rails/ymca_view/public/assets/application-b422f803b56ae2f5c56a648891ec553e.css
[fog][WARNING] Unable to load the 'unf' gem. Your AWS strings may not be properly encoded.
Yep we've got it working in Rails 4 是的,我们可以在Rails 4中使用它
You need to do this: 您需要这样做:
#GemFile (might need aws_sdk gem too)
gem "asset_sync", "~> 1.0.0"
#config/environments/production.rb
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
$-> rake assets:precompile RAILS_ENV=production
We use Figaro to store ENV
vars locally, here's what we got: 我们使用Figaro在本地存储
ENV
var,这是我们得到的:
#config/application.yml
FOG_DIRECTORY: "***BUCKET_NAME****"
FOG_PROVIDER: "AWS"
FOG_REGION: "eu-west-1"
ASSET_SYNC_GZIP_COMPRESSION: "true"
ASSET_SYNC_MANIFEST: "true"
ASSET_SYNC_EXISTING_REMOTE_FILES: "delete"
I didn't need to use the 1.0.0 version. 我不需要使用1.0.0版本。 I used the latest gem, it seems that it doesn't actually upload (at least on EY) when it is in the :assets group.
我使用了最新的gem,当它在:assets组中时,似乎并没有真正上传(至少在EY上)。 I had to add it to the general group in my Gemfile and it worked fine.
我必须将其添加到我的Gemfile中的常规组中,并且工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.