> OK, I was curious as to what was happening, so I looked at the Rails
> startup. I now know what was going wrong.
> During startup, Rails internals and ActiveRecord in particular does a
> lot of trick stuff with method aliasing. If you redefine any (some?)
> of the aliased methods, the redefine takes place after the alias magic
> has taken place, this leaves your code running, but all the code that
> got aliased in gets disconnected. The answer, obviously, is to add
> your method to the alias_method chain...
> Basically, the message is if anything redefines any of the
> ActiveRecord internals, you have to be very careful that you don't
> lose side-effects that you need. This also means you need to do a fair
> amount of digging to discover why some of this stuff breaks.
> When I first replied, I'd hoped it would be more useful!
I think this kind of "magic" programming is found all over the Rails
code base, and can make it frustrating to try to use traditional ruby
techniques, such as the one you describe, to manage the framework. I
believe the Merb guys had exactly this complaint, and now that they're
working with the rails core to integrate the frameworks, I gather that
there is some hope that in the future we'll be able to do overrides and
things like that more easily..
I'm not an expert on this subject by any means, and corrections are
welcome if anyone has more info.