From: Rob Sanheim Date: 2007-12-17T10:37:44+09:00 Subject: Re: magic / counter-magic? (detect loading file?) On Dec 16, 2007 2:52 PM, Giles Bowkett wrote: > Here's something that's puzzling me. > > Somewhere inside Rails is something which loads your .irbrc under some > circumstances. It means that if you have a gem which adds a lot of > methods to Object and which is required by people in their .irbrcs, > sooner or later, your methods on Object are going to collide with > Rails' methods on *anything*. I have such a gem, Utility Belt, and > this happened to somebody who installed it. It's going to happen to a > lot of people, in fact, because the method in question was named > "edit," which practically every Rails app uses. > > I took a look around the Rails file-loading process and it looked > pretty involved. I know the problem comes from > ActiveSupport::Dependencies but that's about it. I'd like to find and > fix the bug in Rails but I just don't have time. What I want to do > instead is set up Utility Belt to recognize when it's being called > from Rails and then have it de-borkify the situation. All I really > need to accomplish that is code which can recognize where it's being > called or loaded from. I know such code, and idioms for using it, > exist, but I'm not sure what they are. Is it just a matter of grepping > against __FILE__? How does my gem determine who it's being loaded by > and send them away if they don't need to be loading it? I have utility_belt 1.0.5, rails 2.0.1, and an app with controllers with edit actions. None of them have shown this bug. How are you sure its really a rails bug, and not just some weird combination of plugins/gems, utility_belt, _and_ rails that causes the error to show on a few unlucky folks apps? - Rob