Class: Cms::Site

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/cms/site.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#logo_fileObject

Returns the value of attribute logo_file.



7
8
9
# File 'app/models/cms/site.rb', line 7

def logo_file
  @logo_file
end

Class Method Details

.find_site(host, path = nil) ⇒ Object

– Class Methods ——————————————————– returning the Cms::Site instance based on host and path



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/models/cms/site.rb', line 58

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

#destroyObject

– 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



75
76
77
78
# File 'app/models/cms/site.rb', line 75

def destroy
  self.class.update_all({:is_mirrored => false}, :id => self.id) if self.is_mirrored?
  super
end