On Wed, Dec 14, 2011 at 12:41 AM, JavierQQ [email protected] wrote:
Well I found the code here:
http://stackoverflow.com/questions/1673812/rails-validation-for-users-email-only-want-it-to-validate-when-a-user-signs-up
validates :score, :presence => true, :if => Proc.new{ (some code
here) }
while this may work in your case, you should remember the following (a
shameless copy
and paste from the api)
Finally, the options :if, :unless, :on, :allow_blank and :allow_nil can
be
given to one specific validator, as a hash:
validates :password, :presence => { :if => :password_required? },
:confirmation => true
Or to all at the same time:
validates :password, :presence => true, :confirmation => true, :if =>
:password_required?
one more thing. I find it cleaner to do what you need like this
validates :score, :presence => {:if => :static?}
def static?
#code here
end
def example?
#code here
end
Cheers!
–
You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–