开发者

sorting posts from query in rails

开发者 https://www.devze.com 2023-03-24 19:09 出处:网络
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 cat

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

0

精彩评论

暂无评论...
验证码 换一张
取 消