Sha256: 1e85192857f539f8b825a637e1a9f1aa4164ee80b1a9b9c0b4aa5a46f2522832
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
class Site < ActiveRecord::Base belongs_to :page attr_accessible :name, :page_id, :stylesheet, :hostnames, :hostnames_attributes has_many :hostnames, :dependent => :destroy accepts_nested_attributes_for :hostnames, :allow_destroy => true def self.find_by_hostname(hostname) Site.joins(:hostnames).where(:hostnames=>{:hostname=>hostname}).first || Site.joins(:hostnames).where(:hostnames=>{:hostname=>'*'}).first end # Monkey-Patch the Page-Controller for loading the right root-Page PagesController.class_eval do def home if (@site) error_404 unless (@page = Page.find(@site.page_id)).present? else error_404 unless (@page = Page.where(:link_url => '/').first).present? end end end # Monkey-Patch the Application-Controller for loading the current site ApplicationController.class_eval do prepend_before_filter :load_site protected def load_site @site = Site.find_by_hostname(request.host) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
refinerycms-multisite-0.0.2 | app/models/site.rb |