Created
March 22, 2019 07:26
-
-
Save deepakmahakale/b8e01d4c686d8eb38d2f4537ad6a6383 to your computer and use it in GitHub Desktop.
This file contains 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(:posts).map do |user| | |
[user.name, user.posts.map(&:title).join(', ')] | |
end | |
User Load (0.2ms) SELECT "users".* FROM "users" | |
Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "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