# Understanding rails internal architecture

**URL:** <https://www.ruby-forum.com/t/understanding-rails-internal-architecture/156810>\
**Category:** Rails\
**Created:** [January 3, 2009, 10:51am UTC](https://www.ruby-forum.com/t/understanding-rails-internal-architecture/156810 "2009-01-03T10:51:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzimmek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jzimmek](https://www.ruby-forum.com/u/jzimmek)\
**Post date:** [January 3, 2009, 10:51am UTC](https://www.ruby-forum.com/t/understanding-rails-internal-architecture/156810/1 "2009-01-03T10:51:20Z")

</div>

i am currently digging into the rails 2.2.2 source to get a deeper  
understanding of some features (in particular model-validation) and a  
better overall insight. most of rails features are encapsulated in a  
separate module - as far as can see - and wired together through  
mixins. this makes sense and following the logic in the single modules  
is easy. but i am getting stuck while puzzling to see it altogether in  
the big picture.

some of my (hopefully correct) assumptions:

a)  
ActiveRecord::Validations::ClassMethods is included in  
ActiveRecord::Base giving each activerecord classmethods like  
“validates\_presence\_of”

b)  
ActiveRecord::Validations calls  
“alias\_method\_chain :save, :validation” to enable the validation  
feature while saving the record

so far so good - but the interaction of class- and instance methods is  
not clear to me. how is the activerecord instance (on which the  
validation will be applied) passed to the “validates\_presence\_of”  
class methods ?

following the flow of control over multiple “aliases and mixins” is  
not very easy, at least for me. i suggest it will relate to  
ActiveSupport::Callbacks, but i am absolutly not sure if this is the  
right direction to go further.

any help is really appreciated.

jan zimmek
