Rails 3 - Devise : How to skip the 'current_password' when editing a registration?

前端 未结 5 2052
无人共我
无人共我 2021-01-30 18:53

I\'ve implemented omniauth with my devise model, so I can authenticate using other services. Password is not necessary anymore for my model, as users can authenticate using twit

5条回答
  •  没有蜡笔的小新
    2021-01-30 19:37

    Similar to above, try putting this in your user model:

    # bypasses Devise's requirement to re-enter current password to edit
    def update_with_password(params={}) 
      if params[:password].blank? 
        params.delete(:password) 
        params.delete(:password_confirmation) if params[:password_confirmation].blank? 
      end 
      update_attributes(params) 
    end
    

提交回复
热议问题