Class: Cms::Site
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cms::Site
- Defined in:
- app/models/cms/site.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_by_domain(domain) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/models/cms/site.rb', line 12 def self.find_by_domain(domain) d = domain.clone strip_www!(d) if site = first(:conditions => {:domain => d}) site else default.first end end |
.strip_www!(d) ⇒ Object
22 23 24 25 |
# File 'app/models/cms/site.rb', line 22 def self.strip_www!(d) return unless d d.sub!(/\Awww./, '') end |
Instance Method Details
#remove_www ⇒ Object
27 28 29 |
# File 'app/models/cms/site.rb', line 27 def remove_www self.class.strip_www!(domain) end |
#set_default ⇒ Object
35 36 37 38 39 |
# File 'app/models/cms/site.rb', line 35 def set_default if self.class.default.count < 1 update_attribute(:the_default, true) end end |
#unset_default ⇒ Object
31 32 33 |
# File 'app/models/cms/site.rb', line 31 def unset_default self.class.update_all(["the_default = ?", false]) if the_default end |