validates_presence_of :zipcode validates_length_of :zipcode :allow_nil => true
I can hold two competing ideas in my head at one time but I don't think that's how code works... On Nov 15, 6:52 pm, "Todd A. Jacobs" <tjacobs-sndr- b4f...@codegnome.org> wrote: > I have a model that includes the following: > > validates_presence_of :zipcode > validates_numericality_of :zipcode, :plus4, :allow_nil=>true > validates_length_of :zipcode, :is=>5, :allow_nil=>true > validates_length_of :plus4, :is=>4, :allow_nil=>true > > The allow_nils are just to prevent the reporting of the same error (say, > a missing zipcode) multiple ways. The problem is that, when the user > enters data into the form: > > <%= f.label :zipcode %>: > <%= f.text_field :zipcode, :maxlength=>5 %>-<%= f.text_field :plus4, > :maxlength=>4 %> > > the validation reports: > > Zipcode is the wrong length (should be 5 characters) > > even when the input *is* five digits (e.g. "99999"). What's going on > here? > > -- > "Oh, look: rocks!" > -- Doctor Who, "Destiny of the Daleks" --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---