[Rails] Re: password validation triggered even I update non-password attribute

2014-08-05 Thread Ronald Fischer
Matt Jones wrote in post #1154197: On Saturday, 2 August 2014 11:41:46 UTC-4, Ruby-Forum.com User wrote: method. because I often have the case that I will update only some of the attributes. I wonder *why* validates looks at attributes which are not part of the update. Is there a use case

[Rails] Re: password validation triggered even I update non-password attribute

2014-08-05 Thread Ronald Fischer
Jason Fb wrote in post #1154202: validates :password, if: lambda { self.registration_state == registered } This is an interesting idea. In my case, user attributes change after creation only if the user updates his profile, or when he clicks on the forgot my password link and I have to create

[Rails] Re: password validation triggered even I update non-password attribute

2014-08-04 Thread Matt Jones
On Saturday, 2 August 2014 11:41:46 UTC-4, Ruby-Forum.com User wrote: Eric Saupe wrote in post #1154001: First change the validates to only validate if a password is being passed. validates :password, length: { minimum: 6 }, :if = :password Second, remove the parameters

[Rails] Re: password validation triggered even I update non-password attribute

2014-08-02 Thread Ronald Fischer
Eric Saupe wrote in post #1154001: First change the validates to only validate if a password is being passed. validates :password, length: { minimum: 6 }, :if = :password Second, remove the parameters for password if the are blank on your update method. if params[:password].blank?

[Rails] Re: password validation triggered even I update non-password attribute

2014-08-01 Thread Eric Saupe
I had this same problem a while ago. The issue comes in the update_attributes since it wants to update all of the attributes that are being passed to it, which is including an empty password. To fix it you'll need to do two things. First change the validates to only validate if a password is