[英]What are best practices for tracing the flow of a large rails app?
If you are a new developer to a large (very large!) rails app it can be really difficult to trace through the flow of what is calling what, where a method is defined, and how to 'grok' how the whole thing works. 如果您是大型(非常大!)rails应用程序的新开发人员,则可能很难跟踪调用什么,定义方法的位置以及如何“了解”整个过程的流程。
What are best practices for how to find information like: 查找信息的最佳做法是什么:
I'm in class Foo and it calls a method bar but there is no def bar in the file. 我在Foo类中,它调用方法栏,但文件中没有def栏。 It must be mixed in or a concern or monkey patched etc. in somehow.
它必须以某种方式混入或担心或打补丁等。 What are steps 1, 2, 3 for where to look?
查找位置的步骤1、2、3是什么? I don't see anything obvious at the top of the file and greping for 'def bar' doesn't return anything.
我没有在文件顶部看到任何明显的内容,并且对“ def bar”进行搜索不会返回任何内容。
Metaprogramming! 元编程! Probably defined the methods on the fly based on the params passed.
可能根据传递的参数动态定义了方法。 Ex.
例如 define_method
define_method
I would go with 我会去
grep "def bar" app/* lib/* -irn (optionally -l)
If I'm in the file open, I most likely would use cscope , because I use vim, but if you are using an IDE it might help you somehow to find this method. 如果打开文件,则很可能会使用cscope ,因为我使用的是vim,但是如果您使用的是IDE,则可能会以某种方式帮助您找到此方法。
Or yet, I could simply use the debugger , where you can inspect your objects in runtime. 但是,我只能使用debugger ,您可以在其中运行时检查对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.