如何知道rails中未使用的路线 [英] how to know unused routes in rails

查看:51
本文介绍了如何知道rails中未使用的路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法知道一段时间内铁路中未使用的路线,或通过任何其他方式,例如通过解析源代码并找出哪些路由未被调用或在某些定义的时间段内未调用的路由.

is there any way to know unused routes in rails over some period, or by any other mean, e.g. by parsing source code and finding out which routes are not called or over some defined period routes those are not been invoked.

我想知道这一点,因为在一个巨大的 Rails 应用程序中,当开发人员开始添加资源:对象"时,它会在运行时创建大量不必要的路由,我不确定这是否会影响性能,但仍然是好奇心.

I would like to know this because in a huge rails app when developers start adding "resources :objects", it gets loads of unnecessary routes created at run time, I am not sure whether this hits the performance, but still the curiosity.

推荐答案

我发现了一个似乎可以做到这一点的 gem:amatsuda/traceroute.我自己还没有尝试过,但从描述来看它做对了 - 检查定义的资源丰富的路由,但没有创建相应的操作.

I found a gem that seems to do this: amatsuda/traceroute. I haven't tried it myself, but judging from the description it does the right thing - checks for resourceful routes that are defined, but a correcponding action is not created.

但我承认,在分析已访问和未访问的链接时应该非常小心.如果没有人访问过此链接,并不意味着将来不会访问它.

But I'd admit one should be very careful with analysing links that are visited and that are not. If no one ever visits this link does not mean it is not going to be visited in the future.

这篇关于如何知道rails中未使用的路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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