未定义的方法`fog_host ='

时间:2012-10-24 00:51:20

标签: ruby-on-rails ruby-on-rails-3 carrierwave fog

当我尝试运行我的应用程序时,我收到以下错误:

  

config / initializers / carrierwave.rb:4:未定义方法`fog_host ='for   CarrierWave :: Uploader :: Base:Class(NoMethodError)

这是我的 initializers / carrierwave.rb 文件:

CarrierWave.configure do |config|
  config.storage = :fog
  config.fog_directory = 'media.domain.pl'
  config.fog_host = 'http://s3-eu-west-1.amazonaws.com/media.domain.pl'

  config.fog_credentials = {
    :provider => 'AWS',
    :aws_access_key_id => '***',
    :aws_secret_access_key => '***',
    :region => 'eu-west-1',
  }
end

carrierwave中包含fogGemfile,并且直到上次使用bundle update才开始工作。您知道我的代码有什么问题吗?我在谷歌找不到任何关于它的信息

ruby​​ v.8.7.7
rails v.3.2.6
雾v 1.6.0
carrierwave v.7.0.0

1 个答案:

答案 0 :(得分:40)

fog_host似乎不是配置选项。在Carrier wave文档中,您可能需要asset_host代替:

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',       # required
    :aws_access_key_id      => 'xxx',       # required
    :aws_secret_access_key  => 'yyy',       # required
    :region                 => 'eu-west-1'  # optional, defaults to 'us-east-1'
  }
  config.fog_directory  = 'name_of_directory'                     # required
  config.fog_public     = false                                   # optional, defaults to true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}
  config.asset_host     = 'https://assets.example.com'            # optional, defaults to nil
end

<强>更新

以下是引入该更改的提交:https://github.com/jnicklas/carrierwave/commit/7046c93d6b23cffef9f171a5f7f0dd14267a7057