LoginSignup
7

More than 5 years have passed since last update.

posted at

updated at

CarrierWave のストレージに fog を使い、S3にファイルを保存したい際に uninitialized constant CarrierWave::Storage::Fog というエラーが出る場合の対処

問題

CarrierWave のストレージに fog を使い、保存先を Amazon S3 にしたい場合、

CarrierWave のドキュメント carrierwaveuploader/carrierwave の設定を参考に fog-aws を導入するとエラーとなります。

gem 'fog-aws'

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

解決

fog-aws の代わりに fog を使いましょう。

gem 'fog'

fog 側で Issue となっています。
CarrierWave 側でファイルが require されていなく、fog側で fog-storage のような gem を提供するなど、別の対応を考えているようです。
https://github.com/fog/fog/issues/3429

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
7