Skip to content

Instantly share code, notes, and snippets.

@rbazinet
Forked from sborsje/host_based_routing.rb
Created December 16, 2009 17:44
Show Gist options
  • Save rbazinet/258007 to your computer and use it in GitHub Desktop.
Save rbazinet/258007 to your computer and use it in GitHub Desktop.
# Host based routing - enables routes like:
# map.connect '', :controller => 'blah', :action => 'blah', :conditions => {:host => 'blah'}
#
# Put this file in /config/initializers
module ActionController
module Routing
class Route
def recognition_conditions_with_host
result = recognition_conditions_without_host
result << 'conditions[:host] === env[:host]' if conditions[:host]
result
end
alias_method_chain :recognition_conditions, :host
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment