Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

closed as too broad by gnat, MichaelT, amon, jwenting, Bart van Ingen Schenau Sep 3 '14 at 13:12

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.


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.

share|improve this answer
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 6 '11 at 14:09
Sorry about that, I misread your question, check edits. – Robert Greiner May 6 '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:

  1. Active Support -- utilities and helper classes which are used throughout the framework.
  2. Active Record -- the object-relational mapping layer.
  3. 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.
  4. 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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.