質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

解決済

1回答

1552閲覧

[RaislTutorial]Herokuにデプロイした際にApplicationErrorが発生する

reijimatsumura

総合スコア16

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

0クリップ

投稿2018/09/06 07:32

自分で調べた中でも同じような質問がいくつか見受けられたのですが、解決に至らなかったので質問させていただきます。

RailsTutorial1.5.2で起こった事象になります。

ローカル上では問題なく動くのですがHerokuへデプロイするとエラーが発生してしまいます。

###実行環境
・Ruby(2.4.4)
・Rails(5.1.6)
・Heroku(7.14.1)

以下がGemfileです

gemfile

1source 'https://rubygems.org' 2 3gem 'rails', '5.1.6' 4gem 'puma', '3.9.1' 5gem 'sass-rails', '5.0.6' 6gem 'uglifier', '3.2.0' 7gem 'coffee-rails', '4.2.2' 8gem 'jquery-rails', '4.3.1' 9gem 'turbolinks', '5.0.1' 10gem 'jbuilder', '2.7.0' 11 12group :development, :test do 13 gem 'sqlite3', '1.3.13' 14 gem 'byebug', '9.0.6', platform: :mri 15end 16 17group :development do 18 gem 'web-console', '3.5.1' 19 gem 'listen', '3.1.5' 20 gem 'spring', '2.0.2' 21 gem 'spring-watcher-listen', '2.0.1' 22end 23 24group :production do 25 gem 'pg', '0.20.0' 26end 27 28# Windows環境ではtzinfo-dataというgemを含める必要があります 29gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

###エラー
以下がエラーが発生した際のHerokuのログとRailsConsoleの出力になります。

HerokuLog

12018-09-06T07:08:09.366804+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch' 22018-09-06T07:08:09.366824+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'2018-09-06T07:08:09.366843+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke' 32018-09-06T07:08:09.366866+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>' 42018-09-06T07:08:09.366890+00:00 app[web.1]: from bin/rails:9:in `require' 52018-09-06T07:08:09.366909+00:00 app[web.1]: from bin/rails:9:in `<main>' 62018-09-06T07:08:09.374706+00:00 app[web.1]: => Booting Puma 72018-09-06T07:08:09.374709+00:00 app[web.1]: => Rails 5.1.6 application starting in production 82018-09-06T07:08:09.374711+00:00 app[web.1]: => Run `rails server -h` for more startup options 92018-09-06T07:08:09.374713+00:00 app[web.1]: Exiting 102018-09-06T07:08:11.863126+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 52611 -e production` 112018-09-06T07:08:15.257052+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to 12your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError) 132018-09-06T07:08:15.257075+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec' 142018-09-06T07:08:15.257084+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection' 152018-09-06T07:08:15.257089+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_handling.rb:58:in `establish_connection' 162018-09-06T07:08:15.257091+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>' 172018-09-06T07:08:15.257092+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval' 182018-09-06T07:08:15.257093+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook' 192018-09-06T07:08:15.257188+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `block in eager_load!' 20 212018-09-06T07:08:15.257365+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch' 222018-09-06T07:08:15.257343+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run' 232018-09-06T07:08:15.257338+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap' 242018-09-06T07:08:15.257393+00:00 app[web.1]: from bin/rails:9:in `<main>' 252018-09-06T07:08:15.264009+00:00 app[web.1]: => Booting Puma 262018-09-06T07:08:15.264012+00:00 app[web.1]: => Rails 5.1.6 application starting in production 272018-09-06T07:08:15.257374+00:00 app[web.1]: from bin/rails:9:in `require' 282018-09-06T07:08:15.264014+00:00 app[web.1]: Exiting 292018-09-06T07:08:15.264013+00:00 app[web.1]: => Run `rails server -h` for more startup options 302018-09-06T07:08:15.327664+00:00 heroku[web.1]: State changed from starting to crashed 312018-09-06T07:08:15.314647+00:00 heroku[web.1]: Process exited with status 1 322018-09-06T07:08:16.063220+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=obscure-reaches-XXXXX.herokuapp.com request_id=cf6826c7-9a76-45bf-9f2b-557c70efd401 fwd="110.4.129.60" dyno= connect= service= status=503 bytes= protocol=https 332018-09-06T07:08:16.703105+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-reaches-XXXXX.herokuapp.com request_id=505a9c20-7b05-4848-92f3-b6bead41ae57 fwd="110.4.129.60" dyno= connect= service= status=503 bytes= protocol=https 34

RailsConsole

1/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError) 2 from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec' 3 from /app/vendor/bundle/ruby/2.4.0/gems/activerecord- 4 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks' 5 from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/base.rb:326:in `<module:ActiveRecord>' 6 from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/base.rb:25:in `<top (required)>' 7 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' 8 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require' 9 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency' 10 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' 11 from /app/app/models/application_record.rb:1:in `<top (required)>' 12 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' 13 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require' 14 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency' 15 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' 16 from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/rails/engine.rb:475:in `each' 17 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `block in eager_load!' 18 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:473:in `each' 19 from /app/vendor/bundle/ruby/2.4.0/gems/railties- 20 from /app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each' 21 from /app/vendor/ruby-2.4.4/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each' 22 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers' 23 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!' 24 from /app/config/environment.rb:5:in `<top (required)>' 25 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require' 26 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require_environment!' 27 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command/actions.rb:16:in `require_application_and_environment!' 28 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/console/console_command.rb:96:in `perform' 29 from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run' 30 from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command' 31 from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch' 32 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform' 33 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke' 34 from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>' 35 from /app/bin/rails:9:in `require' 36 from /app/bin/rails:9:in `<main>'

文字数制限のため一部省略しています。

試したこと  

・gemfileに以下を追記する

gem 'sqlite3', groups: %w(test development), require: false gem 'pg', groups: %w(production), require: false

特に変化なし

同じような質問が増えてしまうことに関しては申し訳ないのですがお力添えよろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

自己解決しました。

databese.ymlがsqliteのままだったためそこを修正したところ正常に動きました。

database.yml

1production: 2 <<: *default 3 adapter: postgresql 4 database: db/production.pg

投稿2018/09/06 08:03

reijimatsumura

総合スコア16

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問