Rails 3.2.13 recogn_path返回约束的路由错误

我的路线中有两条路径,相同的路径指向不同的控制器和动作

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

我的约束类有以下匹配? 方法

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

当我在浏览器中调用url时,这很好用。 但是,这不适用于recogn_path方法。

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

返回路由错误(没有路由匹配),而在浏览器中调用时,因为它被适当地路由。

用户:id => trump存在。

我如何获得recogn_path方法来返回路径详细信息?

显然,这是Rails中的一个错误,请参阅:

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