[英]How can discover controller name and method from a path on Ruby on Rails?
Given a list of paths:给定路径列表:
* /costumers/1
* /home
* /do/something/action-name
How can check the corresponding controller for these without need do the real call?如何在不需要真正调用的情况下检查这些对应的 controller?
I have a spreadsheet with many routes (exported from application analytic [New Relic]).我有一个包含许多路线的电子表格(从应用程序分析 [New Relic] 导出)。 I'm try discover how routes doesn't are being called.
我正在尝试发现如何不调用路线。 This check does not be does programmatically.
此检查不是以编程方式进行的。
I'm using rails 4.2我正在使用导轨 4.2
Thank's谢谢
You would do this with rails routes
which will list all routes, verb, controller, and method.您可以使用将列出所有路线、动词、controller 和方法的
rails routes
来执行此操作。
You can search for certain routes with -g
.您可以使用
-g
搜索某些路线。 rails routes -g /costumers
for example.例如,
rails routes -g /costumers
。 Don't search for /costumers/1
.不要搜索
/costumers/1
。 The 1 is not part of the route, it is the ID of the Costumer to show. 1 不是路线的一部分,它是要显示的 Costumer 的 ID。 Something like
/costumers/:id
. /costumers/:id
类的东西。 If your version does not support -g
, pipe the output to grep
rake routes | grep /costumers
如果你的版本不支持
-g
, pipe output 到grep
rake routes | grep /costumers
rake routes | grep /costumers
or use your pager rake routes | less
rake routes | grep /costumers
或使用您的寻呼机rake routes | less
rake routes | less
. rake routes | less
。
You can also visit http://localhost:3000/rails/info/routes也可以访问 http://localhost:3000/rails/info/routes
See Rails Routing from the Outside In for more.有关更多信息,请参阅从外向内的 Rails 路由。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.