Class: Site

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_hostname(hostname) ⇒ Object



19
20
21
22
23
24
25
# File 'app/models/site.rb', line 19

def self.find_by_hostname(hostname)
  # allow vhost to be added to existing sites
  if Site.count == 0
    Site.create!(:hostname => hostname)
  end
  self.find(:first, :conditions => ["hostname LIKE ?", "%#{hostname}%"])
end

Instance Method Details

#allow_access_for(user) ⇒ Object



10
11
12
13
# File 'app/models/site.rb', line 10

def allow_access_for(user)
  # Site Admins can access all sites. Users can only access sites to which they belong
  user.site_admin? || self.users.include?(user)
end

#homepageObject



15
16
17
# File 'app/models/site.rb', line 15

def homepage
  self.pages.find(:first, :conditions => {:parent_id => nil})
end