Reputation: 4819
I can't find an answer for this elsewhere, so I'm asking here:
How do I "SELECT COUNT
" with data_mapper?
What I've tried:
MyClass.count
MyClass.size
MyClass.all.count
MyClass.all.size
What does work is:
ids = []
MyClass.all.each do |class|
ids << class.id
end
ids.size
But that's a bit horrible. Anyone know any better way?
Upvotes: 0
Views: 35
Reputation: 4330
Your first try was right but if you look at the documentation, count is a aggregate function and therefore you need to install/require dm-aggregates.
Aggregate functions
For the following to work, you need to have dm-aggregates required.
Upvotes: 1