Test2.new.bar
in method_missing
=> nil
Test2.new.foo
in foo
=> nil
why does invoking method bar on the instance find class Test2’s
method_missing instance method, but not instance method foo inherited
from class Test?
You’ve got a class method Test2.bar, but you never call it. (The
program would run the same if you deleted that method.) When you send
the message ‘bar’ to your instance of Test2, it hits method_missing
because there’s no instance method bar in Test2 or any of its
ancestors.
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.