Sha256: 063d7b850a28c0e90ca9f977a88063b28052d2447bd0c318a16083843e788504
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 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.1 | app/models/site.rb |