Permalink
Browse files

Don't need to store these in a plugin as long as they're not extended…

… on every extension.activate
  • Loading branch information...
1 parent 34cff8a commit 3f117a91e91218c5a021663307efb598d3d85472 @joshfrench joshfrench committed Apr 20, 2009
View
4 ...outing/lib/multi_site/route_extensions.rb → lib/multi_site/route_extensions.rb
@@ -16,4 +16,6 @@ def recognition_conditions_with_site
end
end
-end
+end
+
+ActionController::Routing::Route.send :include, MultiSite::RouteExtensions
View
10 ...ng/lib/multi_site/route_set_extensions.rb → lib/multi_site/route_set_extensions.rb
@@ -1,14 +1,16 @@
module MultiSite
module RouteSetExtensions
-
+
def self.included(base)
- base.alias_method_chain :extract_request_environment, :site
+ base.alias_method_chain :extract_request_environment, :site
end
-
+
def extract_request_environment_with_site(request)
env = extract_request_environment_without_site(request)
env.merge! :site => request.host
end
-
+
end
end
+
+ActionController::Routing::RouteSet.send :include, MultiSite::RouteSetExtensions
View
6 multi_site_extension.rb
@@ -18,12 +18,16 @@ class MultiSiteExtension < Radiant::Extension
end
def activate
+ # ActionController::Routing modules are required rather than sent as includes
+ # because the routing persists between dev. requests and is not compatible
+ # with multiple alias_method_chain calls.
+ require 'multi_site/route_extensions'
+ require 'multi_site/route_set_extensions'
Page.send :include, MultiSite::PageExtensions
SiteController.send :include, MultiSite::SiteControllerExtensions
Admin::PagesController.send :include, MultiSite::PagesControllerExtensions
ResponseCache.send :include, MultiSite::ResponseCacheExtensions
Radiant::Config["dev.host"] = 'preview' if Radiant::Config.table_exists?
- # Add site navigation
admin.pages.index.add :top, "site_subnav"
admin.tabs.add "Sites", "/admin/sites", :visibility => [:admin]
end
View
5 vendor/plugins/multi_site_routing/init.rb
@@ -1,5 +0,0 @@
-# Putting these in a plugin is hackish, but it prevents
-# them from getting reloaded in dev mode (which is bad)
-
-ActionController::Routing::RouteSet.send :include, MultiSite::RouteSetExtensions
-ActionController::Routing::Route.send :include, MultiSite::RouteExtensions

0 comments on commit 3f117a9

Please sign in to comment.