This project is archived and is in readonly mode.

#4513 ✓resolved
Ernie Miller

AssociationProxy undef methods call =~ on symbol in Ruby 1.9

Reported by Ernie Miller | April 30th, 2010 @ 08:51 PM

Not sure this can technically count as a bug, since on a stock Ruby 1.9.x the behavior is the same as on 1.8.x, but due to an obscure bug that showed up at http://github.com/ernie/meta_where/issues#issue/1 I tracked down something interesting in AssociationProxy. Since Ruby 1.9 returns symbols in response to Object#methods instead of strings, association_proxy.rb is calling regexps on symbols while undefining methods.

The default behavior on 1.9 is to cast a symbol to string before comparing via regexp, so this issue is masked unless you attempt to do something crazy, like, oh, say, defining a new Symbol#=~, in which case it causes the association proxy to fail to mask the class of an association to be Array, then cascades to the problem outlined in the above github ticket, where the check for association.is_a?(Array) fails in form_helper.rb (fields_for_with_nested_attributes).

A patch is attached. If a test is warranted on this one just let me know and I'm sure I can come up with something. :)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages