Running a pop on a result set from a pgsql database I get:
undefined method `pop' for #<PG::Result:0x0000000273dc08>
I want to get the first 5 of that result set, do something with it, then do it again with the next 5. I don't want to run my query twice as it is a fairly long query.
How would I do this in ruby?
I am running ruby 2.1 and rails 3.0.
PG::Result
isEnumerable
so you could just useeach_slice
on it:If you need to differentiate the iterations then throw a
with_index
into the mix: