Skip to content

Commit

Permalink
Recognize should also work with route is wrapped in a constraint.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jul 5, 2010
1 parent 6671d9c commit 8079484
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -13,6 +13,8 @@ def self.new(app, constraints, request = Rack::Request)
end
end

attr_reader :app

def initialize(app, constraints, request)
@app, @constraints, @request = app, constraints, request
end
Expand Down
2 changes: 2 additions & 0 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -512,6 +512,8 @@ def recognize_path(path, environment = {})
end

dispatcher = route.app
dispatcher = dispatcher.app while dispatcher.is_a?(Mapper::Constraints)

if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false)
dispatcher.prepare_params!(params)
return params
Expand Down
5 changes: 4 additions & 1 deletion actionpack/test/dispatch/routing_test.rb
Expand Up @@ -45,7 +45,10 @@ def self.matches?(request)
match 'account/logout' => redirect("/logout"), :as => :logout_redirect
match 'account/login', :to => redirect("/login")

match 'account/overview'
constraints(lambda { |req| true }) do
match 'account/overview'
end

match '/account/nested/overview'
match 'sign_in' => "sessions#new"

Expand Down

0 comments on commit 8079484

Please sign in to comment.