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 comment:

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



Contact Me for any help regarding rails/nodejs/php/mysql


Email *

Message *