I have a Enumerable object returned from Mongoid (MongoDB object mapper)
using HAML:
= @employees.count
= @employees.class
- @employees.each do |e|
=h e.inspect
the count shows 3 the class shows Enumerable::Enumerator But only 1 item is printed out
the object is returned in the controller using
@employees = Employee.limit(3).where({:_id.gte => startID.to_i})
If I change
- @employees.each do |e|
to
- @employees.to_a.each do |e|
then it prints out all 3, but why will the Enumerable method fail? If I try in rails console using p e
it actually prints out 3 items.