Re: Re: [ruby-81] Sessions & Rails 2.3.2...

From: Steve M.
Sent on: Thursday, August 27, 2009 5:50 AM
> 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!
>
> Brendon.
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.

Steve

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy