NoMethodError: undefined method `confirm!' for #<User

NoMethodError: undefined method `confirm!' for #<User

我正在尝试使用 rails 应用程序编辑器工具创建一个应用程序。我正在使用 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 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

#confirm! 方法已被删除。

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

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