Trying to return biggest count on group sorted model?

This would be a lot easier if you used the :counter_cache feature of ActiveRecord because the numbers would be expressed in a column you could index and sort on. The alternative is to write some custom SQL to get the proper result The alternative is to wrangle around with a group like you have: Country. Find(users.

Group(:country_id).count.first. First).

This would be a lot easier if you used the :counter_cache feature of ActiveRecord because the numbers would be expressed in a column you could index and sort on. The alternative is to write some custom SQL to get the proper result. The alternative is to wrangle around with a group like you have: Country.

Find(users. Group(:country_id).count.first. First).

User model has a :country column. Now I want to find out how many people of the same country are in a specific group and return only the country with the biggest amount of users. Which does not work, I saw it returns an OrderedHash, where I'm now taking the first key of, which is pointless.

Just showing you were I'm lost I guess. I want to be able to do @group. Country and get the biggest country in that group.

Any help on how I would go about this?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions