Rails 3.2.13 path_recognizer returns a routing error for constraints

I have two paths in my routes, the same path pointing to a different controller and action

match '/:id' => 'users#show', :as => 'user', :constraints => UserConstraint match '/:id' => 'customers#show', :as => 'customer' 

Does my restriction class have the following matches? Method

 def self.matches?(request) return User.exists?(request.path_parameters[:id]) end 

this works fine when I call the urls in my browser. however, this does not work for the detect_path method.

 Rails.application.routes.recognize_path("/trump", {:method => :get}) 

returns a routing error (no route matches), while it works when called in the browser, since it is routed accordingly.

there is a user with: id => trump.

How do I get the parameter_recognition method to return path information?

+2
ruby ruby-on-rails ruby-on-rails-3
source share
1 answer

This seems to be a bug in Rails, see

https://github.com/rails/rails/issues/8679

+4
source share

All Articles