From 271c37c00d7f5e6ee1218dace38ddbf3d760f343 Mon Sep 17 00:00:00 2001 From: Daniel Collis-Puro Date: Thu, 25 Jun 2009 17:07:22 -0400 Subject: [PATCH] Require that city and country be included on all new addresses. --- app/models/contact.rb | 2 +- app/views/contacts/edit.html.erb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index c2756ac..d75f44e 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -16,7 +16,7 @@ class Contact < ActiveRecord::Base :reject_if => proc { |attributes| attributes['email'].blank? } accepts_nested_attributes_for :contact_addresses, :allow_destroy => true, - :reject_if => proc { |attributes| attributes['street1'].blank? } + :reject_if => proc { |attributes| (attributes['city'].blank? or attributes['country'].blank?) ? true : false } accepts_nested_attributes_for :contact_urls, :allow_destroy => true, :reject_if => proc { |attributes| attributes['url'].blank? } diff --git a/app/views/contacts/edit.html.erb b/app/views/contacts/edit.html.erb index f77fa7c..96a5c4b 100644 --- a/app/views/contacts/edit.html.erb +++ b/app/views/contacts/edit.html.erb @@ -39,6 +39,7 @@ <% end %> +

City and Country are required on new addresses.

Contact Info