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

71 views
Skip to first unread message

Gary Weaver

unread,
Dec 6, 2013, 12:12:12 PM12/6/13
to rubyonra...@googlegroups.com

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

Akira Matsuda

unread,
Dec 10, 2013, 11:14:04 AM12/10/13
to rubyonra...@googlegroups.com
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!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.



--
Akira Matsuda<ron...@dio.jp>

Akira Matsuda

unread,
Dec 13, 2013, 8:14:54 PM12/13/13
to rubyonra...@googlegroups.com
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 :)

Thanks!
--
Akira Matsuda<ron...@dio.jp>
Reply all
Reply to author
Forward
0 new messages