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