This project is archived and is in readonly mode.

#5188 ✓committed
Ken Collins

Bug In #method_missing For AssociationCollection's Dynamic #create_by_ For 1.8.6

Reported by Ken Collins | July 23rd, 2010 @ 09:04 PM

While using RVM to test an old ruby 1.8.6-p388 on our production servers, I noticed that the create_by_ dynamic method blows up due to how Hash[] args are processed. For instance,

1.8.6

>> Hash[[["post_id", 42], ["skimmer", false]]]
ArgumentError: odd number of arguments for Hash
    from (irb):14:in `[]'
    from (irb):14

1.8.7 & Up

>> Hash[[["post_id", 42], ["skimmer", false]]]
=> {"post_id"=>42, "skimmer"=>false}

The attached patch is not pretty, but it does work the same for all ruby versions. Thoughts on how to make this cleaner? The patch is applied against 2-3-stable and tested under 1.8.6/1.8.7/1.9.1. BTW, there are no tests in this because 4 tests already failed as a result of this.

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>

Pages