Created
January 27, 2019 21:23
-
-
Save Bajena/f58850727f8aeeb107fc24d68cbffef9 to your computer and use it in GitHub Desktop.
Rails includes
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
posts = Post.where(id: [1, 2, 3]).includes(:user) | |
# SELECT * FROM posts WHERE id IN (1, 2, 3) | |
# SELECT * FROM users WHERE id IN (1, 2, 3) | |
users = posts.map { |post| post.user } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment