Created
March 22, 2019 07:28
-
-
Save deepakmahakale/7410cc75a5d08244b076ffdcd658cd3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.includes(:published_posts).map do |user| | |
[user.name, user.published_posts.map(&:title).join(', ')] | |
end | |
User Load (0.3ms) SELECT "users".* FROM "users" | |
Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE (published = 't') AND "posts"."user_id" IN (1, 2, 3) | |
#=> [["Jack", "post-1, post-2"], ["Adam", "post-3, post-3"], ["John", "post-5, post-6"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment