Hello,
I would like to configure rails routing rules based on hostname. From browsing the web I tried adding the following code to my environment.rb:
module ActionController
module Routing
class RouteSet
def extract_request_environmen
t(request)
{ :method => request.method, :hostname => request.server_name }
end
end
class Route
alias_method :old_recognition_condition
s, :recognition_conditions
def recognition_conditions
result = old_recognition_conditions
result << "conditions[:hostname] === env[:hostname]" if conditions[:hostname]
Rails.logger.debug "result = #{result}"
result
end
end
end
end
Then in my routes.rb, I added:
map.connect ':id', :controller => 'landing', :action => 'index', :conditions => { :hostname => 'blah' }
Yet the routing rule seems to be enacted regardless of the hostname. Furthermore the debug code I added to recognition_conditions never seems to get called.