前提・実現したいこと
herokuにrailsで作成したappをあげるため、git push Heroku後、heroku pg:reset DATABASE、heroku run:detached rails db:migrate、そしてheroku run:detached rails db:seedをした後、heroku openをしたところapplication errorが出てしまいます。対処法を教えてください。
発生している問題・エラーメッセージ
Heroku logの結果を以下に示します。(エラー箇所のみ)
2020-03-16T05:12:07.046950+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ancient-scrubland-55684.herokuapp.com request_id=f210e631-ce71-42a6-8192-3629233a0d50 fwd="133.35.37.111" dyno= connect= service= status=503 bytes= protocol=https
heroku heroku run rails cをすると以下のようになります。
Traceback (most recent call last): 47: from /app/bin/rails:9:in `<main>' 46: from /app/bin/rails:9:in `require' 45: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>' 44: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke' 43: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform' 42: from /app/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch' 41: from /app/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command' 40: from /app/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run' 39: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/commands/console/console_command.rb:96:in `perform' 38: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/command/actions.rb:16:in `require_application_and_environment!' 37: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require_environment!' 36: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require' 35: from /app/config/environment.rb:5:in `<top (required)>' 34: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!' 33: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers' 32: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each' 31: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each' 30: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component' 29: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `call' 28: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:347:in `each' 27: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component' 26: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from' 25: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' 24: from /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each' 23: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers' 22: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run' 21: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec' 20: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:67:in `block in <module:Finisher>' 19: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:67:in `each' 18: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:354:in `eager_load!' 17: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:473:in `eager_load!' 16: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:473:in `each' 15: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `block in eager_load!' 14: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `each' 13: from /app/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!' 12: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:11:in `loading' 11: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:149:in `exclusive' 10: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading' 9: from /app/app/models/micropost.rb:1:in `<top (required)>' 8: from /app/app/models/micropost.rb:4:in `<class:Micropost>' 7: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:11:in `loading' 6: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:149:in `exclusive' 5: from /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading' 4: from /app/app/uploaders/picture_uploader.rb:1:in `<top (required)>' 3: from /app/app/uploaders/picture_uploader.rb:6:in `<class:PictureUploader>' 2: from /app/vendor/bundle/ruby/2.6.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:78:in `storage' 1: from /app/vendor/bundle/ruby/2.6.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:78:in `eval' (eval):1:in `storage': uninitialized constant CarrierWave::Storage::Fog (NameError)
該当のソースコード
CarrierWaveに関係しているファイルを以下に全て貼ります
source 'https://rubygems.org' gem 'rails', '5.1.6' gem 'rinku' gem 'bcrypt', '3.1.12' gem 'faker', '1.7.3' gem 'carrierwave', '1.2.2' gem 'mini_magick', '4.7.0' gem 'will_paginate', '3.1.6' gem 'bootstrap-will_paginate', '1.0.0' gem 'puma', '3.9.1' gem 'sass-rails', '5.0.6' gem 'uglifier', '3.2.0' gem 'coffee-rails', '4.2.2' gem 'jquery-rails', '4.3.1' gem 'jquery-ui-rails' gem 'turbolinks', '5.0.1' gem 'jbuilder', '2.7.0' group :development, :test do gem 'sqlite3', '1.3.13' gem 'byebug', '9.0.6', platform: :mri end group :development do gem 'web-console', '3.5.1' gem 'listen', '3.1.5' gem 'spring', '2.0.2' gem 'spring-watcher-listen', '2.0.1' end group :test do gem 'rails-controller-testing', '1.0.2' gem 'minitest', '5.10.3' gem 'minitest-reporters', '1.1.14' gem 'guard', '2.13.0' gem 'guard-minitest', '2.4.4' end group :production do gem 'pg', '< 1.0.0' gem 'fog', '1.42' end # Windows環境ではtzinfo-dataというgemを含める必要があります gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
class PictureUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick process resize_to_limit: [200, 200] if Rails.env.production? storage :fog else storage :file end def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end def extension_whitelist %w(jpg jpeg gif png) end end
if Rails.env.production? CarrierWave.configure do |config| config.fog_credentials = { # Amazon S3用の設定 :provider => 'AWS', :region => ENV['S3_REGION'], # 例: 'ap-northeast-1' :aws_access_key_id => ENV['S3_ACCESS_KEY'], :aws_secret_access_key => ENV['S3_SECRET_KEY'] } config.fog_directory = ENV['S3_BUCKET'] end end
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
開発環境ではエラーは起きません
あなたの回答
tips
プレビュー