From 4dc05706cd580e43683bc7efbe945d5bd45f0795 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 4 Oct 2007 19:10:07 +0000 Subject: [PATCH] ActionItem96: only validate e-mail if filled --- app/models/environment.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/environment.rb b/app/models/environment.rb index 3c0e7cc..b1afae4 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -123,7 +123,7 @@ class Environment < ActiveRecord::Base # only one environment can be the default one validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => _('Only one Virtual Community can be the default one') - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT + validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.nil? }) # ################################################# # Business logic in general @@ -139,4 +139,12 @@ class Environment < ActiveRecord::Base Category.top_level_for(self) end + def default_hostname + if self.domains(true).empty? + nil + else + self.domains.find(:first, :order => 'id').name + end + end + end -- libgit2 0.21.2