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

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

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

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

Heroku

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

Ruby on Rails

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

Q&A

解決済

1回答

372閲覧

Heroku deployは成功するのですが、App crashedというErrorでアプリを開くことができません

knsg16

総合スコア11

Ruby on Rails 5

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

Heroku

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

Ruby on Rails

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

0グッド

0クリップ

投稿2018/07/22 02:10

前提・実現したいこと

前提としては、
RailsでRails tutorialを参考にしながら、オリジナルのWEBアプリを作成しています。
ローカルである程度開発が完了したので、Production環境にも反映させようとして、
Herokuにて、BuildとDeployは成功したのですが、
Application Errorが表示され、画面を開くことができないという状況です。

実現したいことは、
Production環境にて、自分が作成したアプリを公開することです。

もし、同じような問題で困った経験のある方や、なにか解決策をご存知の方は、
ご教授いただけますと幸いです。
また、このように質問するのが初めてなので、前提条件が不足しているかもしれません。
その際は、ご指摘いただけますと幸いです。

発生している問題・エラーメッセージ

Heroku logsで出力したログでは以下のようなメッセージが出力されていました。

... 2018-07-21T22:25:53.429050+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>' 2018-07-21T22:25:53.429067+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' 2018-07-21T22:25:53.429070+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' 2018-07-21T22:25:53.429072+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' 2018-07-21T22:25:53.429090+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' 2018-07-21T22:25:53.429074+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' 2018-07-21T22:25:53.429092+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require' 2018-07-21T22:25:53.429097+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency' 2018-07-21T22:25:53.429099+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require' 2018-07-21T22:25:53.429102+00:00 app[web.1]: from bin/rails:9:in `<main>' 2018-07-21T22:25:53.436628+00:00 app[web.1]: => Booting Puma 2018-07-21T22:25:53.436633+00:00 app[web.1]: => Rails 5.2.0 application starting in production 2018-07-21T22:25:53.436635+00:00 app[web.1]: => Run `rails server -h` for more startup options 2018-07-21T22:25:53.436636+00:00 app[web.1]: Exiting 2018-07-21T22:25:53.755443+00:00 heroku[web.1]: State changed from starting to crashed 2018-07-22T01:46:55.443194+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-oasis-87548.herokuapp.com request_id=4dd0ea73-12fb-41dc-ba69-e097abcc70b7 fwd="153.214.108.108" dyno= connect= service= status=503 bytes= protocol=https 2018-07-22T01:46:56.415441+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pure-oasis-87548.herokuapp.com request_id=e4cbb4e0-db08-4e97-b4e1-acea10d44d5f fwd="153.214.108.108" dyno= connect= service= status=503 bytes= protocol=https

Heroku run rails cで出力されているエラーメッセージは以下の通りですが、
has_one_attachedメソッドを使用したことはなく、どこを修正すればいいのか検討がついていないという状況です。

... 7: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' 6: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.0/app/models/active_storage/blob.rb:16:in `<main>' 5: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.0/app/models/active_storage/blob.rb:23:in `<class:Blob>' 4: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.0/app/models/active_storage/blob.rb:23:in `include' 3: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/concern.rb:122:in `append_features' 2: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/concern.rb:122:in `class_eval' 1: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.0/app/models/active_storage/blob/representable.rb:7:in `block in <module:Representable>' /app/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for #<Class:0x000000000465c3c8> (NoMethodError)

該当のソースコード

Gemfile

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.5.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.0' # Use sqlite3 as the database for Active Record #gem 'sqlite3' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' gem 'bootstrap-sass', '3.3.7' gem 'will_paginate', '3.1.6' gem 'bootstrap-will_paginate', '1.0.0' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'sqlite3', '1.3.13' gem "simplecov", require: false end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :production do gem 'pg', '0.20.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15', '< 4.0' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

試したこと

  1. heroku logsの出力
  2. heroku run rails cの出力
  3. heroku の再起動
heroku restart --app application_name

4.method_missing': undefined method `has_one_attached'をgoogleで検索して、似たような事象は調べて見たのですが、あまり参考になるような結果は得られませんでした。

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

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

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

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

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

guest

回答1

0

ベストアンサー

まず、ローカル環境では正常に動作するかを確認して下さい。
ローカルは大丈夫な場合、Herokuマイグレーションを忘れているケースが多いので heroku run rails db:migrate を試してみて下さい。

投稿2018/07/22 06:03

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

knsg16

2018/07/22 14:24

dyoshikawa さん heroku run rails db:migrateを実行して、production環境で、sqlite3ではなく、pgを使うという設定を諸々していなかったことに気づきました。回答して頂きありがとうございました。非常に助かりました。
退会済みユーザー

退会済みユーザー

2018/07/22 14:41

良かったです。引き続き頑張って下さい。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問