前提・実現したいこと
実現したいことは、heroku上でユーザー登録した際に、ユーザーのメールアドレスへの送信により、アカウントの有効化をすることです。
しかし、実際にユーザー登録すると、エラーのページしか出てきませんでした。
デプロイする前に、heroku run rails:db:migrateを実行すると、以下のエラーが発生してしまったため、これがエラーの原因かもしれないです。
発生している問題・エラーメッセージ
以下がheroku run:rails:db:migrateを実行した時のエラーです。
SyntaxError Plugin: heroku: /home/ubuntu/.local/share/heroku/config.json: Unexpected end of JSON input See more details with DEBUG=* Running rails db:migrate on ⬢ stark-beyond-04633... up, run.8731 (Free) D, [2021-04-20T04:39:32.487233 #4] DEBUG -- : (0.7ms) SELECT pg_try_advisory_lock(3659837284745438685) D, [2021-04-20T04:39:32.504372 #4] DEBUG -- : (1.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC D, [2021-04-20T04:39:32.513763 #4] DEBUG -- : ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]] D, [2021-04-20T04:39:32.525182 #4] DEBUG -- : (0.7ms) SELECT pg_advisory_unlock(3659837284745438685)```
以下がherokuのlogを調べた時(コマンドでheroku logsを打った時)の内容です。
文字数の都合上、重要でないと思ったものは、省いています。
空欄で改行しているところが省いたところです。
module: @oclif/config@1.17.0 task: runHook prerun plugin: heroku root: /snap/heroku/4048 See more details with DEBUG=* 2021-04-20T04:28:08.520710+00:00 app[web.1]: [4] * Process workers: 2 2021-04-20T04:28:08.520710+00:00 app[web.1]: [4] * Preloading application 2021-04-20T04:28:12.693521+00:00 app[api]: Starting process with command `rails db:migrate` by user pyazofi@choco.la 2021-04-20T04:28:13.597455+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:18332 2021-04-20T04:28:13.597496+00:00 app[web.1]: [4] ! WARNING: Detected 1 Thread(s) started in app boot: 2021-04-20T04:28:13.597500+00:00 app[web.1]: [4] ! #<Thread:0x0000557c80f6d9a0@/app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:334 sleep> - /app/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:337:in `sleep' 2021-04-20T04:28:13.604036+00:00 app[web.1]: [4] - Worker 0 (pid: 9) booted, phase: 0 2021-04-20T04:28:13.606730+00:00 app[web.1]: [4] - Worker 1 (pid: 12) booted, phase: 0 2021-04-20T04:28:14.209228+00:00 heroku[web.1]: State changed from starting to up 2021-04-20T04:28:20.893275+00:00 heroku[run.2755]: State changed from starting to up 2021-04-20T04:28:21.289018+00:00 heroku[run.2755]: Awaiting client 2021-04-20T04:28:21.310252+00:00 heroku[run.2755]: Starting process with command `rails db:migrate` 2021-04-20T04:28:30.377645+00:00 heroku[run.2755]: State changed from up to complete 2021-04-20T04:28:34.710023+00:00 app[web.1]: I, [2021-04-20T04:28:34.709822 #12] INFO -- : [b66bb5ec-1adf-4048-8010-89b4e1e5ae31] Started GET "/users" for 61.86.202.104 at 2021-04-20 04:28:34 +0000 INFO -- : [b66bb5ec-1adf-4048-8010-89b4e1e5ae31] Processing by UsersController#index as HTML 2021-04-20T04:28:34.727312+00:00 app[web.1]: I, [2021-04-20T04:28:34.727189 #12] INFO -- : [b66bb5ec-1adf-4048-8010-89b4e1e5ae31] Redirected to https://stark-beyond-04633.herokuapp.com/login 2021-04-20T04:28:34.727519+00:00 app[web.1]: I, [2021-04-20T04:28:34.727453 #12] INFO -- : [b66bb5ec-1adf-4048-8010-89b4e1e5ae31] Filter chain halted as :logged_in_user rendered or redirected 2021-04-20T04:28:34.728359+00:00 app[web.1]: I, [2021-04-20T04:28:34.728284 #12] INFO -- : [b66bb5ec-1adf-4048-8010-89b4e1e5ae31] Completed 302 Found in 11ms (Allocations: 584) 2021-04-20T04:28:34.730708+00:00 heroku[router]: at=info method=GET path="/users" host=stark-beyond-04633.herokuapp.com request_id=b66bb5ec-1adf-4048-8010-89b4e1e5ae31 fwd="61.86.202.104" dyno=web.1 connect=1ms service=27ms status=302 bytes=1318 protocol=https 2021-04-20T04:28:35.190610+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-beyond-04633.herokuapp.com request_id=8fd77512-d6ec-4213-934e-ddac4665c1e5 fwd="61.86.202.104" dyno=web.1 connect=0ms service=16ms status=304 bytes=112 protocol=https 2021-04-20T04:28:42.470076+00:00 app[web.1]: I, [2021-04-20T04:28:42.469979 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Started POST "/users" for 61.86.202.104 at 2021-04-20 04:28:42 +0000 2021-04-20T04:28:42.471205+00:00 app[web.1]: I, [2021-04-20T04:28:42.471125 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Processing by UsersController#create as HTML 2021-04-20T04:28:42.471263+00:00 app[web.1]: I, [2021-04-20T04:28:42.471211 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Parameters: {"authenticity_token"=>"NwhMp+oG/c64FRonGU+V1PGipVe/CWARLpiX0R695hvWzi3ofyyi1D5rTrEhaKuQJCrEj0SIZIgoftQMdzOtrg==", "user"=>{"name"=>"kkk", "email"=>"pyazofi@choco.la", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Create my account"} 2021-04-20T04:28:42.863674+00:00 app[web.1]: D, [2021-04-20T04:28:42.863548 #12] DEBUG -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] (1.7ms) BEGIN 2021-04-20T04:28:42.871556+00:00 app[web.1]: D, [2021-04-20T04:28:42.871469 #12] DEBUG -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] User Exists? (2.2ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER($1) LIMIT $2 [["email", "pyazofi@choco.la"], ["LIMIT", 1]] 2021-04-20T04:28:43.174971+00:00 app[web.1]: D, [2021-04-20T04:28:43.174847 #12] DEBUG -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] User Create (6.1ms) INSERT INTO "users" ("name", "email", "created_at", "updated_at", "password_digest", "activation_digest") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["name", "kkk"], ["email", "pyazofi@choco.la"], ["created_at", "2021-04-20 04:28:42.872138"], ["updated_at", "2021-04-20 04:28:42.872138"], ["password_digest", "$2a$12$C6C.dDtnUx98HfOsou6aSOAnA3XYlwfSbXUgkkg/vjlf0MNSkJ9ti"], ["activation_digest", "$2a$12$6JC5sAcP7IR9yEmjcYVFo.LbHZlRpfQ5E2u.wOce.aQ9AbTqPRU8O"]] 2021-04-20T04:28:43.178360+00:00 app[web.1]: D, [2021-04-20T04:28:43.178297 #12] DEBUG -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] (2.8ms) COMMIT 2021-04-20T04:28:43.183946+00:00 app[web.1]: I, [2021-04-20T04:28:43.183868 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Rendering user_mailer/account_activation.html.erb within layouts/mailer 2021-04-20T04:28:43.186164+00:00 app[web.1]: I, [2021-04-20T04:28:43.186101 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Rendered user_mailer/account_activation.html.erb within layouts/mailer (Duration: 2.1ms | Allocations: 221) 2021-04-20T04:28:43.187169+00:00 app[web.1]: I, [2021-04-20T04:28:43.187108 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Rendering user_mailer/account_activation.text.erb within layouts/mailer 2021-04-20T04:28:43.187699+00:00 app[web.1]: I, [2021-04-20T04:28:43.187639 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Rendered user_mailer/account_activation.text.erb within layouts/mailer (Duration: 0.4ms | Allocations: 166) 2021-04-20T04:28:43.191157+00:00 app[web.1]: D, [2021-04-20T04:28:43.191077 #12] DEBUG -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] UserMailer#account_activation: processed outbound mail in 11.7ms 2021-04-20T04:28:43.232449+00:00 app[web.1]: I, [2021-04-20T04:28:43.232326 #12] INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Delivered mail 607e587b2f28e_c2abe4211e3585334@5b449708-d0dd-4d92-98d6-768cabd052f8.mail (41.0ms) 2021-04-20T04:28:43.232520+00:00 app[web.1]: D, [2021-04-20T04:28:43.232448 #12] DEBUG -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Date: Tue, 20 Apr 2021 04:28:43 +0000 2021-04-20T04:28:43.232521+00:00 app[web.1]: From: noreply@example.com 2021-04-20T04:28:43.232521+00:00 app[web.1]: To: pyazofi@choco.la 2021-04-20T04:28:43.232522+00:00 app[web.1]: Message-ID: <607e587b2f28e_c2abe4211e3585334@5b449708-d0dd-4d92-98d6-768cabd052f8.mail> 2021-04-20T04:28:43.232522+00:00 app[web.1]: Subject: Account activation 2021-04-20T04:28:43.232523+00:00 app[web.1]: Mime-Version: 1.0 2021-04-20T04:28:43.232523+00:00 app[web.1]: Content-Type: multipart/alternative; 2021-04-20T04:28:43.232524+00:00 app[web.1]: boundary="--==_mimepart_607e587b2e284_c2abe4211e35852b8"; ==_mimepart_607e587b2e284_c2abe4211e35852b8 ==_mimepart_607e587b2e284_c2abe4211e35852b8 2021-04-20T04:28:43.232534+00:00 app[web.1]: ----==_mimepart_607e587b2e284_c2abe4211e35852b8-- INFO -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Completed 500 Internal Server Error in 761ms (ActiveRecord: 41.2ms | Allocations: 18697) 2021-04-20T04:28:43.233775+00:00 app[web.1]: F, [2021-04-20T04:28:43.233704 #12] FATAL -- : [bc235dea-fdbd-4333-a375-2fef2ed67ff3] 2021-04-20T04:28:43.233777+00:00 app[web.1]: [bc235dea-fdbd-4333-a375-2fef2ed67ff3] Errno::ECONNREFUSED (Connection refused - connect(2) for nil port 25): 2021-04-20T04:28:43.233777+00:00 app[web.1]: [bc235dea-fdbd-4333-a375-2fef2ed67ff3] app/models/user.rb:65:in `send_activation_email' 2021-04-20T04:28:43.233778+00:00 app[web.1]: [bc235dea-fdbd-4333-a375-2fef2ed67ff3] app/controllers/users_controller.rb:21:in `create' 2021-04-20T04:28:43.233860+00:00 heroku[router]: at=info method=POST path="/users" host=stark-beyond-04633.herokuapp.com request_id=bc235dea-fdbd-4333-a375- 2021-04-20T04:39:15.732567+00:00 app[api]: Starting process with command `rails db:migrate` by user pyazofi@choco.la 2021-04-20T04:39:26.372814+00:00 heroku[run.8731]: State changed from starting to up 2021-04-20T04:39:26.663056+00:00 heroku[run.8731]: Starting process with command `rails db:migrate` 2021-04-20T04:39:35.589374+00:00 heroku[run.8731]: Process exited with status 0 2021-04-20T04:39:35.654617+00:00 heroku[run.8731]: State changed from up to complete
該当のソースコード
下記のgithubのコードです。
https://github.com/yuyakesan/rails_third_man
補足情報(FW/ツールのバージョンなど)
Ruby on Rails:6.0.3
AWS
heroku:7.52.0 linux-x64 node-v12.21.0
あなたの回答
tips
プレビュー