Class: Cms::Site
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cms::Site
- Defined in:
- app/models/cms/site.rb
Class Method Summary collapse
-
.find_site(host, path = nil) ⇒ Object
– Class Methods ——————————————————– returning the 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 Cms::Site instance based on host and path
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/cms/site.rb', line 47 def self.find_site(host, path = nil) return Cms::Site.first if Cms::Site.count == 1 cms_site = nil Cms::Site.find_all_by_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
64 65 66 67 |
# File 'app/models/cms/site.rb', line 64 def destroy self.class.update_all({:is_mirrored => false}, :id => self.id) if self.is_mirrored? super end |