Asset_path在使用CDN时复制前缀“assets”

时间:2014-01-28 19:28:17

标签: ruby-on-rails ruby-on-rails-4 sprockets

我正在使用asset_sync将已编译的资源上传到S3。 但是,当我升级到rails 4时,它正在重复生产中“/ assets”的前置:

<%= asset_path('image.jpg') %>

Wrong: /assets//myapp.s3.amazonaws.com/assets/image.jpg
Correct: //myapp.s3.amazonaws.com/assets/image.jpg

这是我的production.rb:

MyApp::Application.configure do
  config.action_controller.perform_caching = true
  config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
  config.assets.compile = false
  config.assets.digest = true
  config.assets.enabled = true
  config.assets.js_compressor = Uglifier.new(mangle: false)
  config.assets.precompile += %w(static.js vendor.js static.css)
  config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
  config.assets.prefix = "/assets"
  config.static_cache_control = "public, max-age=2592000"
  config.consider_all_requests_local = false
  config.serve_static_assets = true
  config.cache_classes = true  
  config.eager_load = true
end

有什么想法吗? 感谢

1 个答案:

答案 0 :(得分:0)

删除config.assets.prefix = "/assets"