Created
March 13, 2011 17:09
-
-
Save Fonsan/868266 to your computer and use it in GitHub Desktop.
Ugly non threadsafe way of routing a subdomain to a controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SupportSubdomain | |
def self.subdomain | |
@@request.subdomain.to_sym rescue :not_found | |
end | |
def self.matches?(request) | |
@@request = request | |
request.path_parameters[:controller] = request.subdomain | |
Rails.logger.info request.path_parameters[:controller] | |
request.subdomain.presence | |
end | |
end | |
Subroutes::Application.routes.draw do | |
c = Class.new SupportSubdomain | |
constraints(c) do | |
controller c.subdomain do | |
match "(:action)" | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment