Hi, When column''s data type is NUMBER (oracle) validates_length_of doesn''t seem to work. validates_length_of :bsa, :maximum=>3 I get error message even though I didn''t put anything and if I enter something, I get ''size'' is undefined error. If I do that: validates_length_of :bsa, :within => 1..999 , :allow_nil => true I get wrong number of arguments (1 for 0) error. I also googled, but could find specific way of validates length of number data type. thanks in advance, --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 20, 2007 2:15 PM, kimda <kimda-yOgK34DqlZDxlngV0+vsch2eb7JE58TQ@public.gmane.org> wrote:> When column''s data type is NUMBER (oracle) validates_length_of doesn''t > seem to work. > > validates_length_of :bsa, :maximum=>3validates_length_of is for validating string lengths.> I also googled, but could find specific way of validates length of > number data type.Override the validate method in the model. def validate if bsa > 999 errors.add( :bsa, ''too big'' ) if bsa < 1 errors.add( :bsa, ''too small'' ) end -- Greg Donald http://destiney.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Great! It works. Thank you so much! On Nov 20, 3:29 pm, "Greg Donald" <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 20, 2007 2:15 PM, kimda <ki...-yOgK34DqlZDxlngV0+vsch2eb7JE58TQ@public.gmane.org> wrote: > > > When column''s data type is NUMBER (oracle) validates_length_of doesn''t > > seem to work. > > > validates_length_of :bsa, :maximum=>3 > > validates_length_of is for validating string lengths. > > > I also googled, but could find specific way of validates length of > > number data type. > > Override the validate method in the model. > > def validate > if bsa > 999 errors.add( :bsa, ''too big'' ) > if bsa < 1 errors.add( :bsa, ''too small'' ) > end > > -- > Greg Donaldhttp://destiney.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---