I have collection of users with posts, and I'd like to get all the posts from all of the users. Is there a way to do something like this:
User.active.posts.unique.visible
Active and visible are both special scopes that I've written myself.
I have collection of users with posts, and I'd like to get all the posts from all of the users. Is there a way to do something like this:
User.active.posts.unique.visible
Active and visible are both special scopes that I've written myself.
Copyright © 2021 Jogjafile Inc.
Assuming you have
user_idcolumn in yourpoststable:It will generate two SQL queries without any join (unless you use join in your
visiblescope), so it's quite efficient way.