ernie/valium — Issue #8: Valium returns nested array if collection is already loaded
Author: gamov
Created: 2011-12-16 05:03:39+00:00
State: open

I have a Shipment with has_many :shipment_charges (that have a currency attribute).
```
sh.shipment_charges.value_of :currency
=> ["USD", "USD", "USD", "SGD", "SGD"]
```

Then I load the charges
```
sh.shipment_charges
```

I call value_of again:
```sh.shipment_charges.value_of :currency
=>[["USD"], ["USD"], ["USD"], ["SGD"], ["SGD"]]
```

My array is nested... I need to flatten it.

I checked the code and it's strange because it seems that you hit directly the DB. Maybe the cache sends you back directly an array when you are expecting a relation... something like that.
Since this gem is for performance purposes, it's a bit sad to have to call flatten each time.