I was reading the documentation on devise on how to allow users to edit their account without password. Follow their first suggestion, I get an
ActiveRecord::RecordInvalid Exception: Validation failed: Password can't be blank, Password confirmation can't be blank
my controller:
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
I tried the second
def update_resource(resource, params)
resource.update_without_password(params)
end
Same error. So how do I update the user in devise without password and via json