Devise: Edit account without having to confirm password

1

Hello, this is my problem: I have an application (rails 4) with gem 'devise' and gem 'omniauth-facebook' . Who logs in with Facebook at the time of editing the account appears the error "current password can not be blank '... In this way I would like to disable this need to confirm the password or to edit the account. has this tutorial on how to do this: Tutorial

But I do not quite understand what steps are required to do this, I'm new to programming, and the way I'm doing is not working! Thanks!

    
asked by anonymous 28.06.2014 / 05:37

1 answer

0

I think you can do the following:

The update method of the Users controller might look like this:

def update
  if user_params[:password].blank?
   @user.update_without_password(user_params_without_password)
  else
   @user.update(user_params)
  end

 if @user.valid?
  if @user == current_user
    sing_in(@user, baypass: true)
  end
  redirect_to admin_users_url
 else
  render action: 'edit'
 end
end

Where this user_params_without_password is a private method:

def user_params_without_password
    user_params.delete(:password)
    user_params.delete(:password_confirmation)
    user_params
 end

And update_without_password is a ready method of Devise itself.

    
28.06.2014 / 17:58