9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

背景

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 を再起動したところ、エラーは消え、メール送信、アカウント有効化まで確認できた。

9
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?