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

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回答

515閲覧

railsアプリケーションをherokuにデプロイするとエラーが発生します

d0ne1s

総合スコア32

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クリップ

投稿2019/10/03 11:22

前提・実現したいこと

railsアプリケーションをherokuにデプロイすると、エラーが発生します。
(ローカル環境では正しく動作します)

railsチュートリアルを進めており、ローカル環境ではsqlite、本番環境ではpostgresqlの利用を想定しています。

heroku上で以下のようなログが確認できました。

2019-10-03T10:57:48.192973+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-reaches-44565.herokuapp.com request_id=ce717a0a-a4a2-4632-89f3-f468528b2871 fwd="152.165.112.11" dyno= connect= service= status=503 bytes= protocol=https

またターミナルで以下のコマンドを叩くと、

heroku run rails console

次のようなエラーを確認できました。

Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)

heroku上でpostgresqlが正常に動作していないように見受けられます。
以下、gemfileの記述です。

source 'https://rubygems.org' gem 'rails', '5.1.6' 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 '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 :production do gem 'pg', '0.20.0' end

試したこと

■gemfile内

group :production do gem 'pg', '0.20.0' end

部分
・20を19や15などに変更
・gem 'rails_12factor'を追加
変更のたびに「bundle install --without production」やcommit、pushを実行しています。

■app/helpers/application_helper_test.rbをtest/helpers配下に移動

エラーメッセージは変わらずです。
お力を貸していただけますと幸いです。

補足情報(FW/ツールのバージョンなど)

ruby 2.3.7p456
Rails 5.1.6

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

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

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

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

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

suama

2019/10/03 11:36

gem 'pg' (バージョン指定無し)でも、エラーでしょうか? また、database.yml にはproductionの設定は入っていますか?
d0ne1s

2019/10/03 12:46

>gem 'pg' (バージョン指定無し)でも、エラーでしょうか? はい。バージョン無しでもだめでした。 >database.yml にはproductionの設定は入っていますか? productionの設定は入っていますが、postgresやpgという記載はありません。 ここに原因があるかもしれません。 以下、database.yml最下部の記述です production: <<: *default database: db/production.sqlite3
guest

回答1

0

ベストアンサー

Gemfile.lockの内容が重要です。

bundle update

でGemfile.lockの内容を更新し、

git add . git commit -m "comment" git push heroku master

で完全に必要ファイルをコミットして動作確認しても一緒ですか?

投稿2019/10/03 13:15

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

d0ne1s

2019/10/04 10:38

ご回答ありがとうございます。 全て行なっていますが、一緒です。 https://pure-reaches-44565.herokuapp.com/ こちらのページにデプロイしています。 以下、Gemfile.lock内の記述です。 ``` GEM remote: https://rubygems.org/ specs: actioncable (5.1.6) actionpack (= 5.1.6) nio4r (~> 2.0) websocket-driver (~> 0.6.1) actionmailer (5.1.6) actionpack (= 5.1.6) actionview (= 5.1.6) activejob (= 5.1.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (5.1.6) actionview (= 5.1.6) activesupport (= 5.1.6) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionview (5.1.6) activesupport (= 5.1.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) activejob (5.1.6) activesupport (= 5.1.6) globalid (>= 0.3.6) activemodel (5.1.6) activesupport (= 5.1.6) activerecord (5.1.6) activemodel (= 5.1.6) activesupport (= 5.1.6) arel (~> 8.0) activesupport (5.1.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) arel (8.0.0) bindex (0.8.1) builder (3.2.3) byebug (9.0.6) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) concurrent-ruby (1.1.5) crass (1.0.4) erubi (1.9.0) execjs (2.7.0) ffi (1.11.1) globalid (0.4.2) activesupport (>= 4.2.0) i18n (1.7.0) concurrent-ruby (~> 1.0) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) loofah (2.3.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) method_source (0.9.2) mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.12.2) multi_json (1.13.1) nio4r (2.5.2) nokogiri (1.10.4) mini_portile2 (~> 2.4.0) pg (1.1.4) puma (3.9.1) rack (2.0.7) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.1.6) actioncable (= 5.1.6) actionmailer (= 5.1.6) actionpack (= 5.1.6) actionview (= 5.1.6) activejob (= 5.1.6) activemodel (= 5.1.6) activerecord (= 5.1.6) activesupport (= 5.1.6) bundler (>= 1.3.0) railties (= 5.1.6) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) railties (5.1.6) actionpack (= 5.1.6) activesupport (= 5.1.6) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (13.0.0) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) ruby_dep (1.5.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.13) thor (0.20.3) thread_safe (0.3.6) tilt (2.0.10) turbolinks (5.0.1) turbolinks-source (~> 5) turbolinks-source (5.2.0) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (3.2.0) execjs (>= 0.3.0, < 3) web-console (3.5.1) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) PLATFORMS ruby DEPENDENCIES byebug (= 9.0.6) coffee-rails (= 4.2.2) jbuilder (= 2.7.0) jquery-rails (= 4.3.1) listen (= 3.1.5) pg puma (= 3.9.1) rails (= 5.1.6) rails_12factor sass-rails (= 5.0.6) spring (= 2.0.2) spring-watcher-listen (= 2.0.1) sqlite3 (= 1.3.13) turbolinks (= 5.0.1) uglifier (= 3.2.0) web-console (= 3.5.1) BUNDLED WITH 2.0.2 GEM remote: https://rubygems.org/ specs: actioncable (5.1.6) actionpack (= 5.1.6) nio4r (~> 2.0) websocket-driver (~> 0.6.1) actionmailer (5.1.6) actionpack (= 5.1.6) actionview (= 5.1.6) activejob (= 5.1.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (5.1.6) actionview (= 5.1.6) activesupport (= 5.1.6) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionview (5.1.6) activesupport (= 5.1.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) activejob (5.1.6) activesupport (= 5.1.6) globalid (>= 0.3.6) activemodel (5.1.6) activesupport (= 5.1.6) activerecord (5.1.6) activemodel (= 5.1.6) activesupport (= 5.1.6) arel (~> 8.0) activesupport (5.1.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) arel (8.0.0) bindex (0.8.1) builder (3.2.3) byebug (9.0.6) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) concurrent-ruby (1.1.5) crass (1.0.4) erubi (1.9.0) execjs (2.7.0) ffi (1.11.1) globalid (0.4.2) activesupport (>= 4.2.0) i18n (1.7.0) concurrent-ruby (~> 1.0) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) loofah (2.3.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) method_source (0.9.2) mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.12.2) multi_json (1.13.1) nio4r (2.5.2) nokogiri (1.10.4) mini_portile2 (~> 2.4.0) pg (1.1.4) puma (3.9.1) rack (2.0.7) rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.1.6) actioncable (= 5.1.6) actionmailer (= 5.1.6) actionpack (= 5.1.6) actionview (= 5.1.6) activejob (= 5.1.6) activemodel (= 5.1.6) activerecord (= 5.1.6) activesupport (= 5.1.6) bundler (>= 1.3.0) railties (= 5.1.6) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) railties (5.1.6) actionpack (= 5.1.6) activesupport (= 5.1.6) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (13.0.0) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) ruby_dep (1.5.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.13) thor (0.20.3) thread_safe (0.3.6) tilt (2.0.10) turbolinks (5.0.1) turbolinks-source (~> 5) turbolinks-source (5.2.0) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (3.2.0) execjs (>= 0.3.0, < 3) web-console (3.5.1) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) PLATFORMS ruby DEPENDENCIES byebug (= 9.0.6) coffee-rails (= 4.2.2) jbuilder (= 2.7.0) jquery-rails (= 4.3.1) listen (= 3.1.5) pg puma (= 3.9.1) rails (= 5.1.6) rails_12factor sass-rails (= 5.0.6) spring (= 2.0.2) spring-watcher-listen (= 2.0.1) sqlite3 (= 1.3.13) turbolinks (= 5.0.1) uglifier (= 3.2.0) web-console (= 3.5.1) BUNDLED WITH 2.0.2 ```
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問