Rails3 + Devise : prevent password validation when updating

前端 未结 4 1360
Happy的楠姐
Happy的楠姐 2021-01-01 00:23

I\'ve looking for a way to allow users to change their settings (User model) without having to change their password (they still have to enter their current password). Devis

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 01:21

    Add this code to your user model.

    private
    def password_required?
      new_record? ? super : false
    end  
    

提交回复
热议问题