From: Intransition Date: 2010-08-30T07:14:49+09:00 Subject: Re: Broken alias behavior in Ruby 1.9.2? On Aug 29, 5:25 pm, Tron Fu wrote: > The following code works in Ruby 1.8.7 but not in 1.9.2, instead, I get > the error: > NoMethodError: undefined method `old_encode64' for Base64:Module > > Can someone please shed some light on this. > > Thanks in advance, > Tron > > module Base64 >   alias :old_encode64 :encode64 >   module_function # this seems to be necessary -- get a "wrong number of > arguments (2 for 1)" without it this line. > >   def encode64(bin,options={}) >     if (options[:no_line_break] == true) >       old_encode64(bin).gsub(/\n/, '') >     else >       old_encode64(bin) >     end >   end > end Your alias is only creating an instance method, yet you are using it as a class method. To be sure I would need to look at the original code, but presumely module Base64 class << self   alias :old_encode64 :encode64 end end