deviseのsignup時に、confirmed_atメソッドがないと怒られた話

今回の問題

railsのdeviseをインストールしたものの、signupできずに困った。

undefined local variable or method `confirmed_at' for #<User:0x007ff3f0c0bb38>
Did you mean? confirmed?

f:id:kapiba-ra:20180525174259p:plain

 

confirmed_atってメソッド知らないんだけど何ですかそれ、って怒られました。あとはconfirmedが何かってのも知ってるか聞かれてる。このあたりをみていこう。

 

試したこと1

qiita.com

 

20180525045855_devise_create_users.rb のコメントアウトをチェックしてみた。

 

20180525045855_devise_create_users.rb

## Confirmable
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email # Only if using reconfirmable

## Lockable
t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.datetime :locked_at

 

やっぱりちゃんとコメントアウト解除してある。

migrateしてないのかとrake db:migrateも試してみたけど何の変化もなし。

 

今回は諦め

ググってもこれしかやり方が出てこないからとりあえずメール認証を諦めることにする。だからメール認証に関する部分はコメントアウトしておく。

 

と思ったがいじっていたらあちらこちらでメソッドエラーが出てしまったので、deviseのデフォルトに戻しておくことにした。

 

20180525045855_devise_create_users.rb

# ## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmabl
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at

 

 

models/concern/user.rb

class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :omniauthable, omniauth_providers: [:twitter]
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# :lockable, :timeoutable
end

 

デフォルトにしたら発生したエラー

これで終わろうとしていたのだが、なにやら別のエラーを吐かれてしまった。

undefined local variable or method `pages_show_path' for #<#<Class:0x007fe7b6deb868>:0x007fe7b6de3de8>

f:id:kapiba-ra:20180525184604p:plain

 

pages_show_pathっていうパスがないと言われている。

 

試しに該当の箇所をコメントアウトしてみると、表示できた。

とりあえずコメントアウトしたまま進めていこう。

 

もうちょっとしたらここもみていく。

 

構築の参考にしていたエントリー

qiita.com