Yet another bug I’ve found in ruby 1.8
class A
def a
:a
end
end
module M
def a
super
end
alias_method :b, :a
end
class B < A
include M
end
p B.new.a => :a
p B.new.b # in `b': super: no superclass method `a' (NoMethodError)
If you alias a method defined in a module (aliasing the method inside of the module) then calls to super inside that method will no longer work. The fix for this is to alias the method in the class you’ve included the module in, instead of in the module itself. For the lib I’m writing I have a case where this is not possible so that’s why this bug really sucks for me.
This error only occurs in ruby 1.8, it functions correctly in 1.9.
I’ve added a ticket to rubyforge tracker.

[...] are a few gotchas Methods that call super which are defined in modules cannot be aliased because of this bug in ruby 1.8. They must be added to an exception list like [...]
Pingback by Solving the method collision problem of monkey-patching « coderrr — March 31, 2008 @ 2:00 pm
You might want to submit to the tracker on redmine, since that one I think they actually read :)
-R
Comment by roger — July 25, 2008 @ 5:19 am