I am doing an ActiveRecord find on a model as such
@foo = MyModel.find(:all, :select => 'year')
As you can see, I only need the year column from this, so my ideal output would be
["2008", "2009", "2010"]
Instead, though, I get an a hash of the models, with each one containing the year, as such:
[#<MyModel year: "2008">, #<MyModel year: "2009">, #<MyModel year: "2010">]
I can loop through it as such to convert it to my ideal output:
@years = []
for bar in @foo
@years.push(bar.year)
end
but is there a way to retrieve this result to begin with? (i.e. without going through the extra processing?). If there is not, what is a more concise way to do this processing?
Thank you.