> 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
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
> 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
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
> 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
5 matches
Mail list logo