

What is the best way to learn from rails source code? - opti0n

Where to start to read rails source code? Any good references like blog series that discuss the rails source code?
======
shajith
One great starting point is ActiveSupport, specifically the core extensions:

[http://github.com/rails/rails/tree/master/activesupport/lib/...](http://github.com/rails/rails/tree/master/activesupport/lib/active_support/core_ext/)

Though this library isn't really Rails-specific, it has a bunch of self-
contained ruby files, good to learn about the style of doing things elsewhere
in rails.

Examples: Array#uniq_by, String#pluralize, Numeric#hours, etc.

The Rails router, while considerably more complex than ActiveSupport, is also
a self-contained chunk of code you can read:
[http://github.com/rails/rails/tree/master/actionpack/lib/act...](http://github.com/rails/rails/tree/master/actionpack/lib/action_dispatch/routing/)

Also: When reading Rails code (or any ruby library's code, for that matter),
I've found that reading the specs first is very effective.

------
sunkencity
At the first line perhaps. Seriously, it's not that hard. You can also look at
the source of methods at <http://api.rubyonrails.com>

------
spohlenz
Gregg Pollack's talk at <http://confreaks.net/videos/285-lsrc2010-decyphering-
yehuda> is fairly accessible and gives a good overview of some of the newer
refactorings.

------
rbxbx
Learn that 70+ loc method definitions are a terrible thing, and never do it in
your own code :)

