Ruby 2 (not 1.9.3) specific issue with AR when calling alias_method'd destroy vs. super in module-included instance destroy

There is probably a simple reason for this, but haven’t figured it out yet.

If you alias_method destroy on an AR model and then call that method from a module included destroy, it works fine in Ruby 1.9.3 but not Ruby 2.0.0-p247.

The workaround is to call super instead. I’m curious as to why this depends on the Ruby version.

Here is the project to reproduce. I know it is a fringe usage case:

https://github.com/garysweaver/fun_20131206

Thanks

Thank you for a fun report Gary!

We drilled down the problem and we actually could reproduce the same
behavior "off Rails".
So I just filed an issue on the Ruby bug tracker.
http://bugs.ruby-lang.org/issues/9236
I guess you hit a hidden Ruby bug!

And the bug was just fixed via r44175. https://github.com/ruby/ruby/commit/b71956d12b061613f8ef9dfe3f8a75e56dfa799d
So your code would work under Ruby 2.1 which will be shipped at Christmas this month :slight_smile:

Thanks!