[Rails] Re: Validates attributes that aren't even being changed

2011-08-19 Thread 7stud --
Leonel *.* wrote in post #1017341: > I temporarily solved the username attribute by not letting the user > update the username. So the validation only works :on => :create > So username attribute validation problem solved. > > Now I got the password validation problem. Ok, it seems the problem was

Re: [Rails] Re: Validates attributes that aren't even being changed

2011-08-18 Thread Chirag Singhal
Try this :unless => Proc.new {|user| user.password.nil?} Essentially it will check if you are sending a password attribute to the user or not while updating the user record and will check for this validation only if password attribute is present. Chirag http://sumeruonrails.com On Thu, Aug

[Rails] Re: Validates attributes that aren't even being changed

2011-08-18 Thread Leonel *.*
Can someone help me complete this piece of code? I'm thinking about using :unless because the only place where I wouldn't like the password validation is in the Edit User page. validates :password, :presence => true, :length => { :minimum => 6, :maximum => 20, :message => 'should have between 6

[Rails] Re: Validates attributes that aren't even being changed

2011-08-18 Thread Leonel *.*
I temporarily solved the username attribute by not letting the user update the username. So the validation only works :on => :create So username attribute validation problem solved. Now I got the password validation problem. Ok, it seems the problem was kinda of obvious but I couldn't see it. I

Re: [Rails] Re: Validates attributes that aren't even being changed

2011-08-12 Thread Colin Law
On 12 August 2011 16:32, Leonel *.* wrote: > Thanks to everybody for their comments, it's helping me understand Rails > more :) > > I'm going to try your suggestions. > >> Colin Law wrote in post #1016307: >> Having said that I do not understand your comment above, you say you >> get the problem w

[Rails] Re: Validates attributes that aren't even being changed

2011-08-12 Thread Leonel *.*
Thanks to everybody for their comments, it's helping me understand Rails more :) I'm going to try your suggestions. > Colin Law wrote in post #1016307: > Having said that I do not understand your comment above, you say you > get the problem when you try to change the username, but then say that

Re: [Rails] Re: Validates attributes that aren't even being changed

2011-08-11 Thread Hassan Schroeder
On Thu, Aug 11, 2011 at 4:02 PM, Leonel *.* wrote: > Well yeah but even if I take :on => :update away it'll still run the > validation, right? Easiest way to find out is to try it :-) > I've read that Rails runs the validation on "update" and "save" unless > you specify otherwise. If so, then

[Rails] Re: Validates attributes that aren't even being changed

2011-08-11 Thread Leonel *.*
Well yeah but even if I take :on => :update away it'll still run the validation, right? I've read that Rails runs the validation on "update" and "save" unless you specify otherwise. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Googl