Friday, June 26, 2009

Understanding Rrails source code - Day 1

Here I start a series of blog posts about my quest to understand Rails source code.
For the last few days I was reading through ruby meta-programming resources and I think that I am ready for rails internals.

First of all I debuged a very simple app to get a feel of what is going on.
I used NetBeans 6.7 RC3 and created a Rails project. It was fine apart from jRuby being very slow starter so I switched in the project properties to the ruby 1.8.7 which comes with my Ubuntu Intrepid Ibex.

It is convenient to have rails source code (rake rails:freeze:edge) within your application so you can change it without affecting anything beyond your experiments. So I did this but after some time my rails instance stoped behave and I had two options:
  • remove vendor/rails and freeze again or
  • start using some version control to make my changes reversible
I chose the second and cloned source code from the github repository into vendor/rails. I could mess around with the code as mush as I liked and was able to quickly revert it with
git reset --hard HEAD
All those debug sessions gave me understanding of some rails details but I still didn't have a clue of the overall architecture of Rails. I knew that it is based on MVC and that it uses ActiveRecord but that was about it. How those patterns are applied I had no idea.
It is a pity that I could not find a diagram visualizing it. Fortunately Yehuda Katz, one of Rails core developers, at the end of his recent post about Rails 3 architecture promised some visualisations showing what is going on under the hood.

Uff, that was a long day with rails and git. Next time on rails architectural big picture and contributing to rails.

1 comment:

  1. Hi there

    I want to buy the domain ""
    Please let me know how much it costs ?
    I am freelancer new in the field of web desigining, you can xontact me :