From: ao tianlong Date: 2006-12-13T14:47:04+09:00 Subject: Re: how to add a method_missing method into ActiveRecord ------=_Part_256960_4902640.1165988820976 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 1 class Book 2 def method_missing(method_id,*params,&block) 3 print 'original method missing' 4 end 5 6 alias :original_method_missing :method_missing 7 def method_missing(method_id,*params,&block) 8 C(params[:comment])print 'my method missing' 9 original_method_missing(method_id,*prams,&block) 10 end 11 end 12 13 book = Book.new 14 book.tester its looks like work , but output is thod missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missingmy method missintest.rb:9:in `method_missing': stack level too deep (SystemStackError) from test.rb:9:in `method_missing' from test.rb:14 any idia? thank you for your help On 12/13/06, Devin Mullins wrote: > > What Giles said, except: > when /new stuff/: #your code > else original_method_missing(*args,&blk) > Probably makes more sense. > > Giles Bowkett wrote: > > alias :original_method_missing :method_missing > > > > def method_missing(*args) > > case args > > when /normal stuff/ > > original_method_missing(args) > > when /new stuff/ > > # your code goes here > > end > > end > > > > (please bear in mind this is just a sketch.) > > > > > > > > > ------=_Part_256960_4902640.1165988820976--