uninitialized constant CarrierWave::Storage::Fog

probulm

gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'

如果carrierwave是用Multiple file uploads這個版本的話,在使用Fog上傳至S3的時候會出現下面的錯誤訊息

uninitialized constant CarrierWave::Storage::Fog
# backtrace line: ~/app/config/initializers/carrierwave.rb:4 (see below)

solution

1.把Fog改成 gem "fog-aws"
2.touch lib/fog.rb 加一個叫fog的rb檔進lib資料夾
3.

lib.fog.eb
module Fog
  # :D 沒有內容

end

4.修改CarrierWave initializer file

config/initializers/carrier_wave.rb
require 'carrierwave/storage/abstract'
require 'carrierwave/storage/file'
require 'carrierwave/storage/fog'
CarrierWave.configure do |config|

end

參考資料:
Declaring only fog-aws in Gemfile: uninitialized constant CarrierWave::Storage::Fog

comments powered by Disqus