如何在我的 Rails 应用程序中获取所有路线? [英] how get all routes in my rails application?
本文介绍了如何在我的 Rails 应用程序中获取所有路线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在我的 rails 应用程序中获取所有路线吗?我需要一个像 rake routes
这样的输出并将结果放入一个数组中.
can I get all routes in my rails application? I need an output like rake routes
and put the result in an array.
有可能吗?怎么样?
推荐答案
您可以看看 rails 从 rake 任务中吐出这些路由的方式.它在 Rails 2 的 /gems/rails/2.3.x/lib/tasks/routes.rake
中.似乎基本上是在做 ActionController::Routing::Routes.routes
在一般情况下,然后询问.
You could have a look at way rails spits out those routes from the rake task. It's in /gems/rails/2.3.x/lib/tasks/routes.rake
for Rails 2. Seems to be basically doing ActionController::Routing::Routes.routes
in the general case and then interrogating that.
这篇关于如何在我的 Rails 应用程序中获取所有路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文