作業環境
ruby 2.3.1
rails 5.1.5
devise 4.4.3
すでにデバイスで認証機能を使っていましたが今回、確認メールを送る機能を追加しようとしています。
こちらの記事を参考にやってみましたがエラーが出ます。
NameError in Devise::RegistrationsController#create undefined local variable or method `confirmed_at' for #<User:0x007f94f3b4c370> Did you mean? confirmed? Extracted source (around line #432): 430 431 432 433 434 435 else match = matched_attribute_method(method.to_s) match ? attribute_missing(match, *args, &block) : super end end
アカウント認証ページのメールアドレスとパスワードを入力して実行とすると現れます。
行った作業としては
db/migrate/xxxxxxxxxxxx_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
マイグレイト
$ rails db:migrate
app/model/user.rbにて
app/model/user.rb devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable
最後に :confirmableを追加
config/environments/development.rbに
config.action_mailer.smtp_settings = { :enable_starttls_auto => true, :address => "smtp.gmail.com", :port => 587, :domain => 'smtp.gmail.com', :user_name => "xxxxxxx@gmail.com", :password => "xxxxxxxxxxx", :authentication => 'login', }
×××にはメールアドレス、バスワードを記述。
以上です。
グーグルの2段階認証は設定していません。
別の記事では/db/migrate/yyyymmddxxxxxx_add_confirmable_to_devise.rbのようなマイグレイトファイルを作るやり方もあるようで、自分がやったやり方では何か必要なものが抜けているのでしょうか。
すみませんがご教示いただけると幸いです。
よろしくお願いします。
追記
マイグレイト状況です
[vagrant@localhost mymemo]$ rails db:migrate:status database: mymemo_development Status Migration ID Migration Name -------------------------------------------------- up 20180310093943 ********** NO FILE ********** up 20180316050319 Create artists up 20180321002345 Devise create users up 20180321071218 Add user id to artist up 20180322044720 Create stages up 20180322145203 Add artist id to stage up 20180402024450 Add kyokumei to artist up 20180424121356 Add toiawase to artist up 20180509123146 ********** NO FILE ********** [vagrant@localhost mymemo]$ rails db:version Current version: 20180509123146
回答1件
あなたの回答
tips
プレビュー