Ruby-on-rails 注册用户时未定义的局部变量或方法“unconfirmed_email”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9049151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:42:50  来源:igfitidea点击:

Undefined local variable or method `unconfirmed_email' when registering users?

ruby-on-railsruby-on-rails-3devise

提问by varatis

I just installed Devise in my app, configured the views and everything. However, when I click the sign up button I get this error:

我刚刚在我的应用程序中安装了 Devise,配置了视图和所有内容。但是,当我单击注册按钮时,出现此错误:

NameError in Devise::RegistrationsController#create
undefined local variable or method `unconfirmed_email' for #<User:0x00000103721b28>

Why is this? Also, I'm using tlsmail to send emails out through my gmail business account. This might be a problem as well.

为什么是这样?另外,我正在使用 tlsmail 通过我的 gmail 企业帐户发送电子邮件。这也可能是一个问题。

回答by varatis

unconfirmed_email is required for reconfirmable. For some reason this was enabled by default in config/intializers/devise.rb:

重新确认需要 unconfirmed_email。出于某种原因,这是在 config/intializers/devise.rb 中默认启用的:

config.reconfirmable = true

All you have to do is set this to false.

您所要做的就是将其设置为 false。

回答by Fivell

You miss unconfirmed_email column in db.

您错过了数据库中的 unconfirmed_email 列。

add t.reconfirmablein migrations and run rake db:migrate

添加t.reconfirmable迁移并运行rake db:migrate

or if you're using devise >= 2.0

或者如果您使用的是设计 >= 2.0

t.string   :unconfirmed_email