[Rails] Re: Re: Validates attributes that aren't even being changed
Chirag Singhal wrote in post #1017423:
> 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.
Awesomeness!!! Last time I was working on it I was reading about Procs
but the documentation I found was kinda confusing to me. Thanks man! It
works now :D
@7stud I can't do that because I'm validation "password" which is an
attribute that doesn't exist and when update_attributes is ran, it tries
to validate it.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home