>   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
>       errors.add :value, "should be 5 digits"
>     end
>   end
> 
> Good luck,
> 
> -Conrad

Hi, Conrad.  Thank you for the explanation.  My workaround looks similar
to your code and works.  I still have no clue why :if=>Proc.new{...}
didn't work though.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "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.

Reply via email to