Hi, I am not sure if this is already answered in this list. I couldn''t find an answer. So I am posting the question. I have multiple validations for a field. For example: validates_presence_of :contact_email validates_format_of :contact_email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "is not a valid email address" When I submit the form with a blank contact_email I get 2 error messages: Contact email is not a valid email address Contact email can''t be blank If the field is blank the second validations obviously fails. I think Rails should look for blankness of the field and then just show one error message saying it''s a blank field. Any solutions or workarouns? Thanks much. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Love AJAX wrote:> When I submit the form with a blank contact_email I get 2 error messages: > Contact email is not a valid email address > Contact email can''t be blank:allow_nil => true See the Default_Validation_Options under ActiveRecord::Validations::ClassMethods at http://api.rubyonrails.org/ hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Even this doesn''t work. I checked the values of attributes and blank fields are not nil. It appears to be blank. So the validations are taking place. On 3/9/07, Bill Walton <bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> > Love AJAX wrote: > > > When I submit the form with a blank contact_email I get 2 error messages: > > Contact email is not a valid email address > > Contact email can''t be blank > > :allow_nil => true > > See the Default_Validation_Options under > ActiveRecord::Validations::ClassMethods at http://api.rubyonrails.org/ > > hth, > Bill > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---