2013-05-11 62 views
1

我正在使用asset_sync gem在亞馬遜S3上託管我的資產。我已經將config.action_controller.asset_host設置爲指向我的s3存儲桶,以便它可以從s3服務我的資產。config.action_controller.asset_host只適用於動態資產?

但是,只有我的動態生成資產是從s3提供的,其他靜態資產(如圖像)不是從s3提供的,它們只是從相關目錄「/assets/filename.ext」提供。

我該如何獲得rails來將s3用於我的靜態資產,而不僅僅是動態生成的資產?

這裏是我的生產環境中的文件:

config.cache_classes = 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 = false 

# Compress JavaScripts and CSS 
config.assets.compress = true 

# 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 

ENV['FOG_DIRECTORY'] = 'bucket' 
ENV['AWS_ACCESS_KEY_ID'] = 'key' 
ENV['AWS_SECRET_ACCESS_KEY'] = 'key' 
config.action_controller.asset_host = "http://bucket.s3.amazonaws.com" 

config.assets.prefix = "/assets" 

config.assets.initialize_on_precompile = true 
+0

是'config.assets.enabled = TRUE;設置呢? – p1100i 2013-05-11 09:11:21

回答

0

您需要設置低於production.rb

ActionController::Base.asset_host = "http://bucket.s3.amazonaws.com"

相關問題