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
15 16 17 18 19 20 21 22 23 |
# File 'app/models/cms/site.rb', line 15 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
25 26 27 28 |
# File 'app/models/cms/site.rb', line 25 def self.strip_www!(d) return unless d d.sub!(/\Awww./, '') end |
Instance Method Details
#remove_www ⇒ Object
30 31 32 |
# File 'app/models/cms/site.rb', line 30 def remove_www self.class.strip_www!(domain) end |
#set_default ⇒ Object
38 39 40 41 42 |
# File 'app/models/cms/site.rb', line 38 def set_default if self.class.default.count < 1 update_attribute(:the_default, true) end end |
#unset_default ⇒ Object
34 35 36 |
# File 'app/models/cms/site.rb', line 34 def unset_default self.class.update_all(["the_default = ?", false]) if the_default end |