Sha256: 30cbb4acc5f1b53ed82cdc6a41a286742f1464f9217fcb0dcd062626273e67a0
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# Thanks to Jamis Buck for ideas on this stuff # http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2 # This is not yet a working part of SubdomainFu. module SubdomainFu module RouteExtensions def self.included(base) base.alias_method_chain :recognition_conditions, :subdomain end def recognition_conditions_with_subdomain result = recognition_conditions_without_subdomain result << "conditions[:subdomain] === env[:subdomain].to_s" if conditions[:subdomain] && conditions[:subdomain] != true && conditions[:subdomain] != false result << "SubdomainFu.has_subdomain?(env[:subdomain])" if conditions[:subdomain] == true result << "!SubdomainFu.has_subdomain?(env[:subdomain])" if conditions[:subdomain] == false result end end module RouteSetExtensions def self.included(base) base.alias_method_chain :extract_request_environment, :subdomain end def extract_request_environment_with_subdomain(request) env = extract_request_environment_without_subdomain(request) env.merge(:host => request.host, :domain => request.domain, :subdomain => SubdomainFu.subdomain_from(request.host)) end end end ActionController::Routing::RouteSet.send :include, SubdomainFu::RouteSetExtensions ActionController::Routing::Route.send :include, SubdomainFu::RouteExtensions # UrlRewriter::RESERVED_OPTIONS is only available in Rails >= 2.2 # http://www.portallabs.com/blog/2008/12/02/fixing-subdomain_fu-with-named-routes-rails-22/ if Rails::VERSION::MAJOR >= 2 and Rails::VERSION::MINOR >= 2 ActionController::UrlRewriter::RESERVED_OPTIONS << :subdomain end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mbleigh-subdomain-fu-0.1.0 | lib/subdomain_fu/routing_extensions.rb |