简体   繁体   English

跟踪大型Rails应用程序流的最佳实践是什么?

[英]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.

相关问题 国际化最佳实践/ Rails应用程序 - Internationalization Best Practices / Rails App 将大型数据集导入MongoDB的最佳做法是什么? - What are the best practices for importing large datasets into MongoDB? 在 Rails 应用程序中处理大文件上传的最佳方法是什么? - What is the best approach to handle large file uploads in a rails app? 在Rails中使用框架(或iframe)的最佳做法是什么? - What are best practices for using frames (or iframes) with Rails? Rails 前端的最佳实践是什么? - What's the best practices for frontend in Rails? 在Rails中生成“ widgetized”内容的最佳实践是什么 - What are the best practices to generate “widgetized” content in Rails Ruby on Rails 上的 Slim 模板,最佳实践是什么 - Slim templates on Ruby on Rails, what are best practices Rails 应用中 static 页面的最佳实践 - Best practices for static pages in rails app 将Rails应用程序与外部API集成的最佳实践? - Best practices for integrating Rails app with external APIs? 将现有Sinatra应用程序(+ datamapper)迁移到Rails 3(+活动记录)的最佳实践是什么? - What are the best practices for migrating an existing Sinatra app (+datamapper) to Rails 3 (+active record)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM