This project is archived and is in readonly mode.

#3590 ✓resolved
pedm

Problem using merge conditions with orderedhashes

Reported by pedm | December 17th, 2009 @ 04:43 AM

Hi there - when I merge two ordered hashes, the merge works but does not respond to its more advanced settings. In particular, when I run the following code:

pos = Trade.sum("quantity", :conditions => {:buyer_id=>34}, :group => "traded_item_id")
neg = Trade.sum("quantity", :conditions => {:seller_id=>34}, :group => "traded_item_id")
pos.merge(neg){ |key, oldval, newval| oldval-newval }

The value that comes out is not the custom merge, but plain old:
pos.merge(neg)

To put this in a bit more context,
pos = #2}>
neg = #4}>

and the result is:

4}>

when it should be:

-2}>

So yeah, I've been using ruby on rails for about a year, and would love to help. So if someone could tell me where to start on this, I'd love to solve this for you guys. Thanks!
Pat

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

Referenced by

Pages