Class Site
In: app/models/site.rb
Parent: ActiveRecord::Base

Methods

Public Class methods

[Source]

    # File app/models/site.rb, line 12
12:   def self.find_by_domain(domain)
13:     d = domain.clone
14:     strip_www!(d)
15:     if site = first(:conditions => {:domain => d})
16:       site
17:     else
18:       default.first
19:     end
20:   end

[Source]

    # File app/models/site.rb, line 22
22:   def self.strip_www!(d)
23:     return unless d
24:     d.sub!(/\Awww./,'')
25:   end

Public Instance methods

[Source]

    # File app/models/site.rb, line 27
27:   def remove_www
28:     self.class.strip_www!(domain)
29:   end

[Source]

    # File app/models/site.rb, line 35
35:   def set_default
36:     if self.class.default.count < 1
37:       update_attribute(:the_default, true)
38:     end
39:   end

[Source]

    # File app/models/site.rb, line 31
31:   def unset_default    
32:     self.class.update_all(["the_default = ?", false]) if the_default
33:   end

[Validate]