[英]Devise edit user without password
我正在阅读有关如何允许用户无需密码即可编辑其帐户的devise文档 。 遵循他们的第一个建议,我得到了
ActiveRecord::RecordInvalid Exception: Validation failed: Password can't be blank, Password confirmation can't be blank
我的控制器:
class UserPreferencesController < Devise::RegistrationsController
def update_profile
@user = User.find(current_user.id)
if @user.update!(account_params)
sign_in @user, :bypass
render json: [], status: 201
else
render json: [], status: 422
end
end
def account_params
params[:user].permit(:first_name, :last_name, :email, :sex, :phone_number, :location, :birthday)
end
end
我尝试了第二
def update_resource(resource, params)
resource.update_without_password(params)
end
同样的错误。 那么我该如何在没有密码的情况下通过json更新用户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.