我不确定如何配置环境,以便在本地运行应用程序(开发)和加载到heroku(生产环境)后的s3时,Carrier Wave将使用本地文件存储
在开发存储中:文件
在生产存储中:s3
最佳答案
可以选择模型,也可以全局设置。看看https://github.com/jnicklas/carrierwave/tree/v0.5.2的v0.5.2(当前gem)自述文件
在底部附近,有一些有关配置测试环境的说明。使用相同的方法将不同的配置用于“开发”和“生产”,例如将文件“carrierwave.rb”添加到“config / initialisers”并添加配置代码
if Rails.env.test? or Rails.env.cucumber?
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
end
end
为了发展
if Rails.env.development?
CarrierWave.configure do |config|
config.storage = :file
end
end
和生产
if Rails.env.production?
CarrierWave.configure do |config|
config.storage = :s3
end
end
关于ruby-on-rails - 配置环境以在本地和Heroku上的Amazon上使用文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5371126/