I'm an experienced developer which quite some experience in meta programming. I just found my way to Ruby and want to understand more of Rails (and related) project internals. Even if I understand the high level concepts, it's hard to get an overview of those projects. I wonder how other people approach that problem? How would you for example approach the Mongoid source code to get a good understanding of it's internals?
2 Answers
edit
I hate to recommend another book, but I think this one pretty much has what you are looking for. Personally, I like the structure and completeness that books provide when getting into something that I'm unfamiliar with (which, consequently, is a lot of stuff)
Code Reading: The Open Source Perspective
If you are new to Rails, the best thing you can do is start from the beginning. Learn the framework and code up a couple of projects. This will get you accustomed to the "Rails way" of doing things.
Once you are comfortable with Rails, you can start diving in deeper to really understand how things work behind the scenes.
I recommend this book to start out. It's a little on the basic end, but it does provide a good starting off point in my opinion.
As far as Mongoid goes, you could check out their contributor page to learn more about what they are looking for, or delve right into their github project and get into the code.

- 1,667
- 11
- 14
-
Sorry, but I know how to learn new stuff and what books are good for. ;-) And regarding "... delve right into their github project and get into the code.": That's exactly what my questions is targeting at. But I was asking for hints how to get started reading the code. Not how to get started with Rails. – Achim May 06 '11 at 14:09
-
Sorry about that, I misread your question, check edits. – Robert Greiner May 06 '11 at 14:29
When you study the Rails implementation, you can broadly "cut it up" into several big pieces, and work on them one by one. I would take them in this order:
- Active Support -- utilities and helper classes which are used throughout the framework.
- Active Record -- the object-relational mapping layer.
- Action Pack -- this is the "core" of Rails; it handles HTTP requests, routes them to a controller and method, invokes the controller, then renders the template.
- Command-line tools, initialization code, interface with the underlying web server.
Active Support and Active Record both "stand alone" and are not dependent on the rest of the framework, which makes them easier to decipher. That is why I recommend you start with those two. When studying Active Record, you will also want to look at the code for the ARel gem -- AR doesn't make much sense without it.
When you are ready to tackle Action Pack, you might want to start with the request router, which is also fairly "stand-alone".
When studying each part, read the RDocs first. Rails is well-documented, and before you dive into the code, that documentation will give you a good overview of what classes are there, and what each one is for. That will also help you choose a good place to start reading the code.

- 1,308
- 9
- 14