没有s3存储的载波

时间:2014-02-23 14:13:15

标签: ruby-on-rails-3 amazon-s3 carrierwave

我使用载波进行图片上传和测试目的我不想使用s3存储。

这是carrierwave.rb文件

CarrierWave.configure do |config|
  config.permissions = 0666
  config.directory_permissions = 0777
  config.fog_directory = 'xxx-development'
  config.storage = :file
  config.enable_processing = false
end

在ImageUploader类中我有

storage :file

def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

version :thumb do
  process resize_to_fill: [300, 300]
end

当我推送到heroku时,我收到以下错误:

rake aborted!
Fog provider can't be blank, Fog directory can't be blank

我做错了什么?

1 个答案:

答案 0 :(得分:1)

如果你想要它有条件,或许在fog_directory上设置一个环境条件?

CarrierWave.configure do |config|
  config.permissions = 0666
  config.directory_permissions = 0777
  config.fog_directory = 'xxx-development' unless Rails.env.development?
  config.storage = :file
  config.enable_processing = false
end