I have a form that allows users to enter up to 5 names and phone numbers at once. However, I''m having a problem getting the validation to work properly. Here''s the behavior I''d like to see: 1. If a name is entered for a row, Rails should validate both the name and phone number to verify its presence and assure it''s properly formated. 2. If no data is entered for a row, Rails should ignore it by not validating it or adding it to the database. One way I figured out how to get the first requirement working is by adding an if statement to my validation helpers. For example: validates_presence_of :name, :phone, :if => Proc.new{ |person| !person.name.blank? } This will only perform validation on a row if the name is filled in. The problem is, if only 3 out of the 5 rows on the form are completed, Rails will add the blank rows to the database. Is there a way to prevent this while still allowing users to enter less than 5 names at a time? -- 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 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 -~----------~----~----~----~------~----~------~--~---