Answer the question
In order to leave comments, you need to log in
How to show only the count when querying .group().count in Rails?
Subscriber.all.count => 7
Subscriber.group(:id).count => {12=>1, 13=>1}
Why does group give me a hash, not an absolute number ???
How to decide?
Answer the question
In order to leave comments, you need to log in
What does it mean to decide? In the code , the
absolute quantity is returned, and in the code
, Grouped by the id field.
What other result would you like to see?
Subscriber.group(:id).count => {12=>1, 13=>1}
I looked at the answer about count with parameters and it became interesting that I don’t know about count. It turned out (in 4 rails) that
a rather meaningless expression and is equivalent to Subscriber.count
. To be convinced of this, it is enough to read the raw , by the way, in 5 rails, the second parameter from count has already been cut out ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question