[Rails] Re: validation problems

2010-02-11 Thread Ichiro Saga
> validates_numericality_of :value, :only_integer => true, :allow_blank > => > true # make sure that it's an integer > validate :number_of_digits > # make sure that we have five digits > > private > > def number_of_digits > unless self.value.to_s.size == 5

[Rails] Re: validation problems

2010-02-10 Thread Ichiro Saga
Sharagoz -- wrote: >> validates_size_of :value, :is=>9, :message=>"must be 5-digit number", >> :if=>Proc.new{|u| u.value.is_a?(Numeric)} > Looks corrent to me. Maybe the name of the field "value" is causing a > conflict somewhere. Try to rename the field to something else just to > test. Thanks S

[Rails] Re: validation problems

2010-02-10 Thread Sharagoz --
> validates_size_of :value, :is=>9, :message=>"must be 5-digit number", > :if=>Proc.new{|u| u.value.is_a?(Numeric)} Looks corrent to me. Maybe the name of the field "value" is causing a conflict somewhere. Try to rename the field to something else just to test. -- Posted via http://www.ruby-for

[Rails] Re: validation problems

2010-02-09 Thread Ichiro Saga
E. Litwin wrote: >> validates_numericality_of :value, :only_integer=>true, >> :allow_blank=>true >> validates_size_of :value, :is=>9, :message=>"must be 5-digit number", >> :if=>Proc.new{|u| u.value.is_a?(Numeric)} > > Try it as u.is_a?(Numeric) Thanks Litwin. I tried that before but it made the

[Rails] Re: validation problems

2010-02-09 Thread E. Litwin
> validates_numericality_of :value, :only_integer=>true, > :allow_blank=>true > validates_size_of :value, :is=>9, :message=>"must be 5-digit number", > :if=>Proc.new{|u| u.value.is_a?(Numeric)} Try it as u.is_a?(Numeric) -- You received this message because you are subscribed to the Google Group