【发布时间】:2016-08-18 21:58:24
【问题描述】:
here好像也有类似的问题,但是没有人能回答。好像也有点不一样。
我正在从 rails 4.2.4 升级到 Rails 5.0.0.1。 当我尝试在 30 天后运行密码过期时,它会执行更新操作,在第二行出现问题:
def update
resource.extend(Devise::Models::DatabaseAuthenticatablePatch)
if resource.update_with_password(resource_params)
warden.session(scope)['password_expired'] = false
set_flash_message :notice, :updated
sign_in scope, resource, :bypass => true
redirect_to stored_location_for(scope) || :root
else
clean_up_passwords(resource)
respond_with(resource, action: :show)
end
end
这是运行的模块:
module Devise
module Models
module DatabaseAuthenticatablePatch
def update_with_password(params, *options)
new_password = params[:password]
new_password_confirmation = params[:password_confirmation]
result = if new_password.present? && new_password_confirmation.present?
update_attributes(params, *options)
else
self.assign_attributes(params, *options)
self.valid?
self.errors.add(:password, new_password.blank? ? :blank : :invalid)
self.errors.add(:password_confirmation, new_password_confirmation.blank? ? :blank : :invalid)
false
end
clean_up_passwords
result
end
end
end
end
点击update_attributes(params, *options)时发生错误
然后我得到这个错误。
undefined method `<<' for #<OldPassword::ActiveRecord_AssociationRelation:0x007ffe59a0ffa0>
如果有人能帮我解决这个问题,那就太棒了。
提前谢谢你。
【问题讨论】:
标签: ruby-on-rails devise ruby-on-rails-5