I am working with Active Record 2.1.x and there is a file called
dirty.rb. Now I might be missing something but within the function
write_attribute_with_dirty there is a call to
write_attribute_without_dirty. Where is the definition for this
function? What happens after this call?
that’s a common idiom in Rails. They are using an alias to the original
“write_attribute” so they can intercept the calls to write_attribute, do
whatever is needed for the “dirty” functionality and then call to the
original “write_attribute” (without_dirty).
you can do this by using several alias statements or you can use the
alias_method_chain method provided by the Rails API.
by using the strategy of naming/aliasing the methods using the
with/without suffix, you can be (almost) sure that even if you are
aliasing a method that was already aliased, everything will be peachy.
AFAIK in Rails 3 this could change, since the Merb guys are not happy
(and with a reason) about so many levels of indirection and the
complexity introduced in the code. But as of now, it’s a common pattern
all throughout Rails code and plugins.
…i do ruby on rails development in madrid, spain, at
…you can find out more about me on http://formatinternet.wordpress.com