Forum: Ruby on Rails understanding rails internal architecture

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
jzimmek (Guest)
on 2009-01-03 11:51
(Received via mailing list)
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
This topic is locked and can not be replied to.