app/models/locomotive/extensions/site/subdomain_domains.rb in locomotive_cms-2.0.0.rc12 vs app/models/locomotive/extensions/site/subdomain_domains.rb in locomotive_cms-2.0.0

- old
+ new

@@ -4,11 +4,11 @@ module SubdomainDomains def enable_subdomain_n_domains_if_multi_sites # puts "multi_sites? #{Locomotive.config.multi_sites?} / manage_domains? #{Locomotive.config.manage_domains?} / heroku? #{Locomotive.heroku?} / bushido? #{Locomotive.bushido?}" - if Locomotive.config.multi_sites? || Locomotive.config.manage_domains? + if Locomotive.config.multi_sites_or_manage_domains? ## fields ## field :subdomain field :domains, :type => Array, :default => [] @@ -21,11 +21,12 @@ validates_exclusion_of :subdomain, :in => Locomotive.config.reserved_subdomains validates_format_of :subdomain, :with => Locomotive::Regexps::SUBDOMAIN, :allow_blank => true validate :domains_must_be_valid_and_unique ## callbacks ## - before_save :add_subdomain_to_domains + before_save :add_subdomain_to_domains + after_destroy :clear_cache_for_all_domains ## named scopes ## scope :match_domain, lambda { |domain| { :any_in => { :domains => [*domain] } } } scope :match_domain_with_exclusion_of, lambda { |domain, site| { :any_in => { :domains => [*domain] }, :where => { :_id.ne => site.id } } @@ -79,9 +80,13 @@ if not domain =~ Locomotive::Regexps::DOMAIN self.errors.add(:domains, :invalid_domain, :value => domain) end end + end + + def clear_cache_for_all_domains + self.domains.each { |name| Rails.cache.delete(name) } end end end