[Rails-core] Re: Model.find_by_attribute only called the first time

2009-11-09 Thread Hiro Protagonist
I'm working with BIND files and DNS. Sometimes the method isn't called from a controller. Sometimes it will be called from a cron tab and script/runner On Nov 9, 4:30 pm, Matt Jones wrote: > On Nov 9, 2009, at 7:06 PM, Hiro Protagonist wrote: > > > > > I just wanted a :before_find hook, saw the

[Rails-core] Re: Model.find_by_attribute only called the first time

2009-11-09 Thread Matt Jones
On Nov 9, 2009, at 7:06 PM, Hiro Protagonist wrote: > > I just wanted a :before_find hook, saw the mail history from here > during 2006 and they said do > > def find > # Before Find. > super > # After Find > end > > But now we know how that turns out. > > Ultimately it isn't important to my app,

[Rails-core] Re: Model.find_by_attribute only called the first time

2009-11-09 Thread Hiro Protagonist
I just wanted a :before_find hook, saw the mail history from here during 2006 and they said do def find # Before Find. super # After Find end But now we know how that turns out. Ultimately it isn't important to my app, but it would be nice when me or users forget trailing .s Thanks, Chris Lun

[Rails-core] Re: Model.find_by_attribute only called the first time

2009-11-09 Thread Ryan Bigg
I've just realised that because this is a dynamic finder the "power" of method_missing is what's going to stop you from being able to alias this method. This method appears to not be defined until method_missing catches it and defines it then. I've tried also calling the method before aliasing it (

[Rails-core] Re: Model.find_by_attribute only called the first time

2009-11-09 Thread Hiro Protagonist
Koz and Ryan, Now that you point it out, I see how #method_missing calls find, then find thinks I'm retarded and over writes my method by doing a class eval. Thus removing my original code. Am I figuring that right? I've always had trouble generating aliases to singleton methods. I seem to rec

[Rails-core] Re: Model.find_by_attribute only called the first time

2009-11-09 Thread Michael Koziarski
> May I suggest aliasing the method instead of trying to call super? > alias_method :old_find_by_name, :find_by_name > def Person.find_by_name(*params) >   params.first.chop! if params.first.last == "." >   old_find_by_name(params) > end super won't work here because the method isn't defined on a

[Rails-core] Re: Model.find_by_attribute only called the first time

2009-11-09 Thread Ryan Bigg
May I suggest aliasing the method instead of trying to call super? alias_method :old_find_by_name, :find_by_name def Person.find_by_name(*params) params.first.chop! if params.first.last == "." old_find_by_name(params) end 2009/11/10 Hiro Protagonist > > # This is a sanitized example of wh