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

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

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

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

Q&A

1回答

4356閲覧

AmazonS3登録後にApplication Errorが出ました。

Sugisan

総合スコア14

Ruby on Rails

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

0グッド

0クリップ

投稿2018/07/16 05:37

編集2018/07/28 10:26

*初学者です。お手柔らかにご教示頂けますと幸いです。

Herokuでアップロードした画像が時間経つと消える問題が発生していたので、記事通りにAmazon S3を登録してプログラムを書いて、Git commitして、heroku openしたらブラウザ上で以下のようなエラー文が表示されました。

Ruby

1Application error 2An error occurred in the application and your page could not be served. 3If you are the application owner, check your logs for details.

https://アプリ名.herokuapp.com/)
よくわからないエラー文だったので、heroku logsで確認しました。

ログには以下のエラーが繰り返されていました。

Ruby

12018-07-28T03:50:29.821941+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=xxxxxxxxxxxx.com request_id=host=xxxxxxxxxxxx fwd="host=xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=https 22018-07-28T03:50:35.328051+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=host=xxxxxxxxxxxx.com request_id=xxxxxxxxxxxx fwd="xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=https 32018-07-28T04:27:52.249864+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=xxxxxxxxxxxx.com request_id=host=xxxxxxxxxxxx fwd="host=xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=https 42018-07-28T04:27:52.665188+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=host=xxxxxxxxxxxx.com request_id=xxxxxxxxxxxx fwd="xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=https 52018-07-28T07:32:44.528767+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=xxxxxxxxxxxx.com request_id=host=xxxxxxxxxxxx fwd="host=xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=httpsheroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=xxxxxxxxxxxx.com request_id=host=xxxxxxxxxxxx fwd="host=xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=httpsheroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=xxxxxxxxxxxx.com request_id=host=xxxxxxxxxxxx fwd="host=xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=https 62018-07-28T07:32:44.971320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=host=xxxxxxxxxxxx.com request_id=xxxxxxxxxxxx fwd="xxxxxxxxxxxx" dyno= connect= service= status=503 bytes= protocol=https 72018-07-28T07:41:04.312419+00:00 app[api]: Starting process with command `bin/rails console` by user XXXXXXXXXXX 82018-07-28T07:41:14.211907+00:00 heroku[run.3441]: Awaiting client 92018-07-28T07:41:14.283555+00:00 heroku[run.3441]: Starting process with command `bin/rails console` 102018-07-28T07:41:14.289348+00:00 heroku[run.3441]: State changed from starting to up 112018-07-28T07:41:26.906739+00:00 heroku[run.3441]: Process exited with status 1 122018-07-28T07:41:26.921985+00:00 heroku[run.3441]: State changed from up to complete 132018-07-28T09:23:25.195336+00:00 app[api]: Starting process with command `bin/rails console` by user XXXXXXXXXXX 142018-07-28T09:23:36.926778+00:00 heroku[run.7888]: State changed from starting to up 152018-07-28T09:23:36.856143+00:00 heroku[run.7888]: Awaiting client 162018-07-28T09:23:36.916641+00:00 heroku[run.7888]: Starting process with command `bin/rails console` 172018-07-28T09:23:49.706539+00:00 heroku[run.7888]: Process exited with status 1 182018-07-28T09:23:49.725755+00:00 heroku[run.7888]: State changed from up to complete 192018-07-28T09:28:45.022500+00:00 app[api]: Starting process with command `rails db:migrate` by user XXXXXXXXXXX 202018-07-28T09:28:55.395241+00:00 heroku[run.1816]: State changed from starting to up 212018-07-28T09:28:55.331343+00:00 heroku[run.1816]: Awaiting client 222018-07-28T09:28:55.567885+00:00 heroku[run.1816]: Starting process with command `rails db:migrate` 232018-07-28T09:29:06.794224+00:00 heroku[run.1816]: Process exited with status 0 242018-07-28T09:29:06.966385+00:00 heroku[run.1816]: State changed from up

こんな感じです。

heroku run consoleをしてみると、以下のようにも表示されてしまいます。

Ruby

1Running console on ⬢ XXXXXXXXXXX... up, run.5382 (Free) 2/app/vendor/bundle/ruby/2.3.0/gems/aws-sigv4-1.0.3/lib/aws-sigv4/signer.rb:517:in `extract_credentials_provider': Cannot load `Rails.config.active_storage.service`: (Aws::Sigv4::Errors::MissingCredentialsError) 3missing credentials, provide credentials with one of the following options: 4 - :access_key_id and :secret_access_key 5 - :credentials 6 - :credentials_provider 7 from /app/vendor/bundle/ruby/2.3.0/gems/aws-sigv4-1.0.3/lib/aws-sigv4/signer.rb:121:in `initialize' 8 from /app/vendor/bundle/ruby/2.3.0/gems/aws-sdk-s3-1.17.0/lib/aws-sdk-s3/plugins/s3_signer.rb:189:in `new' 9 from /app/vendor/bundle/ruby/2.3.0/gems/aws-sdk-s3-1.17.0/lib/aws-sdk-

まとまらない文章で申し訳ございません。
どたなかご教示頂けますと幸いです。

よろしくお願い致します。

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

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

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

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

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

takahashim

2018/07/25 17:45

出ているエラーは https://teratail.com/questions/48188 と似ているようですね。この感じだと、このエラー行だけを見てもわからないので、残りのログも掲載していただく必要がありそうです。 ちなみに `heroku run rails console` は正常に実行できますか?
Sugisan

2018/07/28 10:18

類似エラーをご教示頂きありがとうございます。今回で言うとどこの部分を修正すれば良いのか解明することができず、ログの追記および”heroku run rails console”の表示結果も追記致しました。ご確認頂けますと幸いです。。
takahashim

2018/07/28 12:36

追記ありがとうございます。なるほどです。詳しくは回答に書いておきますね。
Sugisan

2018/07/30 14:22 編集

@takahashim ご回答頂きありがとうございます! ご指摘頂いた部分を重点的にみて怪しい部分を直しました! 根本的な確認ミスなのですが、今までプッシュ先を誤ったところにしていたようで行った変更がリモートリポジトリにうまく反映されておりませんでした。別で質問を立てさせて頂くので、プッシュが成功しましたら改めて確認しベストアンサーとさせて頂きます。汗
guest

回答1

0

heroku run rails consoleの結果は分かりやすいですね。
この中では、

Cannot load `Rails.config.active_storage.service`: (Aws::Sigv4::Errors::MissingCredentialsError) missing credentials, provide credentials with one of the following options:

といった辺りがポイントで、要するにクレデンシャルがない(あるいは正しく受け取れてない)、ということのようです。

最近のRailsではActiveStorageで画像のアップロードもできるようになったのですが、AWS S3を使うには認証のためのクレデンシャルが必要です。その設定に問題があるようです。リンク先で紹介されているqiitaの記事を見ながら、

  • config/master.key
  • config/credentials.yml.enc
  • config/storage.yml
  • config/environments/production.rb

辺りを確認して、それとheroku config:set RAILS_MASTER_KEY=xxxxxといった処理も行って、どうなるか試してみてください。

投稿2018/07/28 12:39

takahashim

総合スコア1877

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問