I'm currently writing a ruby function that gets a table from a database and then based on the data creates an array. It's written like this:
def listSome
@foos = Array.new
FooTable.find(:all) do |foo|
@foos << foo if foo.name == "Bar"
end
end
The problem I'm having is that only the first element of the query is getting added to the array. I've checked that FooTable.find(:all) returns what I think it should in the console and also that it's ok to loop off of it's results (I printed the results on every loop, it found what it was looking for). I suspect, however, there is something about concatenation to arrays/collections that I don't understand. Why am I only getting the first result of the query added into my array? Thanks.