I am using the following queries in a customer model call to obtain my desired set of transactions.
transactions = sub_account.transactions
transaction_items = transactions.map{|transaction| [transaction.transaction_items]}
However, this is returning an array of an array of hashes. From the rails console
[ [# <TransactionItem id: 29, amount: 20>, #<TransactionItem id: 35, amount: 40>],<br>
[# <TransactionItem id: 31, amount: 30>, #<TransactionItem id: 38, amount: 30>],<br>
[# <TransactionItem id: 43, amount: 30>, #<TransactionItem id: 21, amount: 40>],<br>
]
This process works well. But now I am trying to run a where query on transaction_items but can't becuase they're embedded in the array. Here is my final desired query that I am unable to run.
transaction_items.where(:amount => 30).sum("amount")
I know you can Zip an array, but can you unzip it? I can't find any documentation on it. If no unzip, can I adapt the where query to work on the embedded arrays?
Thanks.