Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What is going on with this article?

More than 1 year has passed since last update.

@yfuzii

Railsチュートリアル 第11章 11.4 「本番環境でのメール送信」 で詰まったところ

背景

Railsチュートリアル 11.4 「本番環境でのメール送信」の最後

$ git push heroku
$ heroku run rails db:migrate

上記コマンド入力後、アカウント有効化を試すために新規登録をしたところ

問題

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f31343139312f64623165656132302d633330652d303633392d356462332d3162666533656637616162612e706e67.png

We're sorry, but something went wrong. と表示。

$ heroku logs

でエラーをチェック。

> Completed 500 Internal Server Error in 173ms (ActiveRecord: 3.5ms)
> NoMethodError (undefined method `activation_digest=' for #<User:0x00007fa1dc755a78>
> Did you mean?  activation_token=):

db:migrate したはずなのに、 activation_digest が定義されていないと言われる。
rails db:migrate:status で確認。

$ rails db:migrate:status
> Status   Migration ID    Migration Name
> --------------------------------------------------
>   up     20181101025217  Create users
>   up     20181101055629  Add index to users email
>   up     20181101105719  Add password digest to users
>   up     20181103133504  Add remember digest to users
>   up     20181104140053  Add admin to users
>   up     20181109103710  Add activation to users

$ heroku run rails db:migrate:status
> Status   Migration ID    Migration Name
> --------------------------------------------------
> D, [2018-11-10T15:06:18.842062 #4] DEBUG -- :    (1.1ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
>   up     20181101025217  Create users
>   up     20181101055629  Add index to users email
>   up     20181101105719  Add password digest to users
>   up     20181103133504  Add remember digest to users
>   up     20181104140053  Add admin to users
>   up     20181109103710  Add activation to users

開発環境、本番環境ともに Add activation to users は migrate されている。

解決

$ heroku restart

Heroku を再起動したところ、エラーは消え、メール送信、アカウント有効化まで確認できた。

4
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
4
Help us understand the problem. What is going on with this article?