Gary Weaver
2013-Dec-06 17:12 UTC
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 -- 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-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@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
2013-Dec-10 16:14 UTC
Re: Ruby 2 (not 1.9.3) specific issue with AR when calling alias_method''d destroy vs. super in module-included instance destroy
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! On Sat, Dec 7, 2013 at 2:12 AM, Gary Weaver <garysweaver@gmail.com> wrote:> 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 > > -- > 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-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@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<ronnie@dio.jp> -- 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-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@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
2013-Dec-14 01:14 UTC
Re: Ruby 2 (not 1.9.3) specific issue with AR when calling alias_method''d destroy vs. super in module-included instance destroy
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! On Wed, Dec 11, 2013 at 1:14 AM, Akira Matsuda <ronnie@dio.jp> wrote:> 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! > > > On Sat, Dec 7, 2013 at 2:12 AM, Gary Weaver <garysweaver@gmail.com> wrote: > >> 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 >> >> -- >> 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-core+unsubscribe@googlegroups.com. >> To post to this group, send email to rubyonrails-core@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<ronnie@dio.jp> >-- Akira Matsuda<ronnie@dio.jp> -- 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-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.