私の本番環境 -
# Code is not reloaded between requests
config.cache_classes = true
config.assets.enabled = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true
config.static_cache_control = "public, max-age=31536000"
# Compress JavaScripts and CSS
config.assets.compress = true
config.assets.js_compressor = :uglifier
#config.assets.css_compressor = :yui
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
# See everything in the log (default is :info)
config.log_level = :warn
config.log_tags = [:remote_ip, lambda { |req| Time.now }]
# Enable serving of images, stylesheets, and JavaScripts from an asset server
ActionController::Base.asset_host = Proc.new { |source|
unless source.starts_with?('/stylesheets' || '/javascripts')
"//dddd.cloudfront.net/"
end
}
ただし、image_tag を使用すると、資産ホストへの絶対 URL ではなく「/assets..」相対 URL が返されます。
irb(main):034:0> helper.image_tag('noimage.gif')
=> "<img alt=\"Noimage\" src=\"/assets/noimage.gif\" />"
irb(main):035:0> helper.image_path('noimage.gif')
何が欠けているのか分かりません。簡単な config.asset_host 設定を試してみましたが、それでも設定が認識されません。