Class: Comfy::Cms::Site
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comfy::Cms::Site
- Defined in:
- app/models/comfy/cms/site.rb
Class Method Summary collapse
-
.find_site(host, path = nil) ⇒ Object
– Class Methods ——————————————————– returning the Comfy::Cms::Site instance based on host and path.
Instance Method Summary collapse
-
#destroy ⇒ Object
– Instance Methods —————————————————– When removing entire site, let’s not destroy content from other sites Since before_destroy doesn’t really work, this does the trick.
Class Method Details
.find_site(host, path = nil) ⇒ Object
– Class Methods ——————————————————– returning the Comfy::Cms::Site instance based on host and path
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/comfy/cms/site.rb', line 37 def self.find_site(host, path = nil) return Comfy::Cms::Site.first if Comfy::Cms::Site.count == 1 cms_site = nil Comfy::Cms::Site.where(:hostname => real_host_from_aliases(host)).each do |site| if site.path.blank? cms_site = site elsif "#{path.to_s.split('?')[0]}/".match /^\/#{Regexp.escape(site.path.to_s)}\// cms_site = site break end end return cms_site end |
Instance Method Details
#destroy ⇒ Object
– Instance Methods —————————————————– When removing entire site, let’s not destroy content from other sites Since before_destroy doesn’t really work, this does the trick
54 55 56 57 |
# File 'app/models/comfy/cms/site.rb', line 54 def destroy self.class.where(:id => self.id).update_all(:is_mirrored => false) if self.is_mirrored? super end |