Friday, July 18, 2008

validate positive integer value in model - Ruby on Rails

validates_inclusion_of :some_attribute,

:within => 1..1.0/0,

:message => 'should be positive'

here 1.0/0 it means infinity...

So the attribute is validate within positive. It is done in rails with validates_inclusion_of for numeric data.


1 comments:

Priyank Shah said...

hi, chirag
Thanks for give me details about validate positive integer values in model in ruby.
Actully i m new to ruby.

Thanks

Post a Comment

Send Email to Me