nested array .select statment


the array is like this
i want to select the parts of the array with the minimum value
and show the 2nd part of the element only meaning the strings like "h"
and "g"

i've tried this but it doesn't work{|c| c.first = [x.min{|a,b| a.first <=> b}.first]}.last

and i get comparison of Array with Array failed

ok i managed to get this out
smallest = x.min{|x,y| x[0] <=> y[0]}[0]
result ={|g| g[0] == smallest}.map{|g|g[1]}
and it works

but the problem is when i apply it to my app

because [[1,"h"],[2,"g"]]
is actually [[groceries.price,"h"]]

and it gives

undefined method `[]' for #<BigDecimal:b69b1e44,'0.3E1',4(8)>

meaning that theres something wrong with groceries.price

but in the migration file .price is specified to be
t.decimal :price, :precision => 8, :scale => 2

I don't understand why rails is giving an undefined method

when i subsitute in decimals for 1 and 2 in the array it is ok.

Solved should not use x for block variable