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.
Class Method Details
.find_site(host, path = nil) ⇒ Object
– Class Methods ——————————————————– returning the Cms::Site instance based on host and path
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/cms/site.rb', line 37 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(host).each do |site| if site.path.blank? cms_site = site elsif "#{path}/".match /^\/#{Regexp.escape(site.path.to_s)}\// cms_site = site break end end return cms_site end |