耙子流产了! NameError:未初始化的常量CarrierWave :: Uploader :: Base :: Fog

时间:2016-09-08 02:33:15

标签: ruby-on-rails

将我的应用程序推送到Heroku后,我运行heroku run rake db:migrate,然后发生错误:

  耙子流产了!   NameError:未初始化的常量CarrierWave :: Uploader :: Base :: Fog

我搜索了我的文档,没有'CarrierWave :: Uploader :: Base :: Fog'

1 个答案:

答案 0 :(得分:1)

我知道为什么现在。谢谢大家〜

由于我的团队成员已删除gem "fog",而是使用carrierwave-aws,但仍然在{wavener.rb}中保留config.fog_credentials。当我将config.fog_credentials更改为config.aws_credentials时,我可以正常heroku run rake db:migrate

我的Gemfile:

gem "carrierwave"
gem "mini_magick"
gem "gravatarify"
gem "seo_helper"
gem "font-awesome-sass"
gem "carrierwave-aws"
gem "figaro"
gem "aasm"
gem "redcarpet"
gem "acts_as_list"

我之前的carrierwave.rb(错误):

CarrierWave.configure do |config|
  if Rails.env.production?
    config.storage :aws
    config.fog_credentials = {
      provider: "AWS", # required
      aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"], # required
      aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
      region: ENV["AWS_BUCKET_REGION"] # required
    }
    config.aws_bucket = ENV["AWS_BUCKET_NAME"] # required
  else
    config.storage :file
  end
end

我当前的carrierwave.rb(正常):

CarrierWave.configure do |config|
  if Rails.env.production?
    config.storage :aws
    config.aws_credentials = {
      provider: "AWS", # required
      aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"], # required
      aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
      region: ENV["AWS_BUCKET_REGION"] # required
    }
    config.aws_bucket = ENV["AWS_BUCKET_NAME"] # required
  else
    config.storage :file
  end
end