I have made a query on posts
(which is included in a has_man开发者_JS百科y belongs_to assoc. with users). So, with this query, I have a selection of posts
in @selected_posts
is there any way I can categorize and sort the users that have posts included in this query and sort them by name with a count of posts? ( Like Mike (6) as link to Mike's 6 posts) for example?
You can use group_by. There is excellent documentation on this in the api docs here http://apidock.com/rails/Enumerable/group_by
精彩评论