Module: Locomotive::Extensions::Site::SubdomainDomains
- Included in:
- Site
- Defined in:
- app/models/locomotive/extensions/site/subdomain_domains.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
Instance Method Details
#enable_subdomain_n_domains_if_multi_sites ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/locomotive/extensions/site/subdomain_domains.rb', line 6 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_or_manage_domains? ## fields ## field :subdomain field :domains, type: Array, default: [] ## indexes index domains: 1 ## validations ## validates_presence_of :subdomain validates_uniqueness_of :subdomain 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 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 } } } send :include, InstanceMethods end end |