【问题标题】:NoMethodError: undefined method `confirm!' for #<UserNoMethodError:未定义的方法“确认!”对于#<用户
【发布时间】:2016-12-06 05:31:43
【问题描述】:

我正在尝试使用 rails app composer 工具创建一个应用程序。我正在使用Deviseconfirmable。我收到错误

rake db:seed
rake aborted!
NoMethodError: undefined method `confirm!' for #<User:0xa0b26ec>

在安装过程中。

user.rb 文件已经有:confirmable

  devise :database_authenticatable, :registerable, :confirmable,
     :recoverable, :rememberable, :trackable, :validatable

我无法做到rake db:seed

【问题讨论】:

  • 您使用的 DEVISE 版本是什么?

标签: ruby-on-rails ruby ruby-on-rails-4 rake


【解决方案1】:

Devise 4.2.0 已弃用 confirm! 方法,您必须改用confirm

4.2.0 - 2016-07-01

移除:-

Remove the deprecated Devise::ParameterSanitizer API from Devise 3. Please use the #permit and #sanitize methods over #for.

Remove the deprecated OmniAuth URL helpers. Use the fully qualified helpers (user_facebook_omniauth_authorize_path) over the scope based helpers ( user_omniauth_authorize_path(:facebook)).

Remove the Devise.bcrypt method, use Devise::Encryptor.digest instead.

Remove the Devise::Models::Confirmable#confirm! method, use confirm instead.

Remove the Devise::Models::Recoverable#reset_password! method, use reset_password instead.

Remove the Devise::Models::Recoverable#after_password_reset method.

从这里,

Remove the Devise::Models::Confirmable#confirm! method, use confirm instead.

Here is the refference

【讨论】:

  • 如果我的回答对您有帮助,您可以接受吗?如果你愿意的话。
【解决方案2】:

#confirm! 方法已被删除。

https://github.com/plataformatec/devise/commit/26e22d8e953184b38a87f3a9b935db32258637d5

您必须使用旧版本,或者最好切换到#confirm 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    • 1970-01-01
    • 1970-01-01
    • 2015-02-22
    • 2016-11-21
    • 1970-01-01
    相关资源
    最近更新 更多