开发者

sorting posts from query in rails

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜