diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2013-01-15 13:38:10 +0000 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2013-01-15 17:21:33 +0000 |
commit | 90d2802b71a6e89aedfe40564a37bd35f777e541 (patch) | |
tree | f0d52164eeb95337282aa5140eda1188092ee0ca /actionpack/lib/action_dispatch/journey/router.rb | |
parent | b28fc685a98e6ff1a3777116b97b5c1c41e01391 (diff) | |
download | rails-90d2802b71a6e89aedfe40564a37bd35f777e541.tar.gz rails-90d2802b71a6e89aedfe40564a37bd35f777e541.tar.bz2 rails-90d2802b71a6e89aedfe40564a37bd35f777e541.zip |
Add support for other types of routing constraints
This now allows the use of arrays like this:
get '/foo/:action', to: 'foo', constraints: { subdomain: %w[www admin] }
or constraints where the request method returns an Fixnum like this:
get '/foo', to: 'foo#index', constraints: { port: 8080 }
Note that this only applies to constraints on the request - path
constraints still need to be specified as Regexps as the various
constraints are compiled into a single Regexp.
Diffstat (limited to 'actionpack/lib/action_dispatch/journey/router.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/router.rb | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb index 1fc45a2109..31868b1814 100644 --- a/actionpack/lib/action_dispatch/journey/router.rb +++ b/actionpack/lib/action_dispatch/journey/router.rb @@ -131,11 +131,7 @@ module ActionDispatch } routes.concat get_routes_as_head(routes) - routes.sort_by!(&:precedence).select! { |r| - r.constraints.all? { |k, v| v === req.send(k) } && - r.verb === req.request_method - } - routes.reject! { |r| req.ip && !(r.ip === req.ip) } + routes.sort_by!(&:precedence).select! { |r| r.matches?(req) } routes.map! { |r| match_data = r.path.match(req.path_info) |