Rails 包罗万象/通配路线 [英] Rails catch-all/globbing routes

查看:38
本文介绍了Rails 包罗万象/通配路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 rails 3.0.14,我正在使用足智多谋的风格构建 routes.rb.我想要一个通配符路由来捕获与任何指定路由不匹配的所有请求.

I am using rails 3.0.14, and I am constructing routes.rb using the resourceful style. I'd like to have a wildcard route that catches all requests that do not match to any route stated.

构建这样一条路线的合适方法是什么?

What's the appropriate way to construct such a route?

推荐答案

put

match '*path' => 'your_controller#your_action'

在 routes.rb 文件的末尾.这很重要,因为路由是自上而下的.

at the end of the routes.rb file. This is important, since the routes are stepped through top down.

另见 http://guides.rubyonrails.org/routing.html -> 3.10

See also http://guides.rubyonrails.org/routing.html -> 3.10

这篇关于Rails 包罗万象/通配路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆