Ruby on rails 3 Rails 3.1-在routes.rb中,使用通配符匹配'*';没有任何路线

Ruby on rails 3 Rails 3.1-在routes.rb中,使用通配符匹配'*';没有任何路线,ruby-on-rails-3,exception-handling,routing,wildcard,Ruby On Rails 3,Exception Handling,Routing,Wildcard,在我的pages\u controller.rb文件中,我有一个not\u found操作。我希望在我的routes.rb文件中有任何与条目不匹配的路由,以转到页面#未找到。为了利用通配符,我将此作为routes.rb文件的最后一行: match '*' => 'pages#not_found' match 'foobar' => 'pages#not_found' 这是基于我在ruby路由指南中读到的通配符(http://guides.rubyonrails.org/v3.1.

在我的
pages\u controller.rb
文件中,我有一个
not\u found
操作。我希望在我的
routes.rb
文件中有任何与条目不匹配的路由,以转到
页面#未找到
。为了利用通配符,我将此作为routes.rb文件的最后一行:

match '*' => 'pages#not_found'
match 'foobar' => 'pages#not_found'
这是基于我在ruby路由指南中读到的通配符(http://guides.rubyonrails.org/v3.1.0/routing.html). 但是它不起作用。我没有去
页面#找不到
,而是得到:
AcctionController::RoutingError(没有与[get]“*”
匹配的路由)(不幸的是,ActionDispatch捕捉到了这一点,因此我没有办法处理异常。)

故障排除时,我将其放在routes.rb文件中:

match '*' => 'pages#not_found'
match 'foobar' => 'pages#not_found'
http://localhost:3000/foobar
如预期。我尝试了部分通配符:

match 'foo*' => 'pages#not_found'
根据Rails指南,这应该与匹配,但它不匹配。要使通配符在路由中工作,您需要做些特殊的事情吗?我缺少什么?

也许可以尝试以下方法:

match '*path' => 'pages#not_found'
也许可以试试这个:

match '*path' => 'pages#not_found'