lib/refinerycms-multisite.rb in refinerycms-multisite-0.0.5 vs lib/refinerycms-multisite.rb in refinerycms-multisite-0.0.6
- old
+ new
@@ -17,10 +17,39 @@
}
end
end
end
end
+
+ module SiteModel
+ extend ActiveSupport::Concern
+
+ included do
+ 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
+ end
+
+ module ClassMethods
+ def find_by_hostname(hostname)
+ Site.joins(:hostnames).where(:hostnames=>{:hostname=>hostname}).first ||
+ Site.joins(:hostnames).where(:hostnames=>{:hostname=>'*'}).first
+ end
+ end
+
+ module InstanceMethods
+ end
+ end
+
+ module SiteModelClassMethods
+ #include ActiveRecord
+
+ end
end
module PagesControllerSite
def home_with_site
if (@site)
@@ -42,6 +71,6 @@
::PagesController.class_eval do
include PagesControllerSite
alias_method_chain :home, :site
end
end
-end
\ No newline at end of file
+end