-
-
Save tbuehlmann/5897229 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
# get all users | |
@users = User.all | |
# get users from given ids | |
ids = [2, 1, 3, 4, 5] | |
@users = User.find(ids) |
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
[17] pry(main)> ids = User.all.map(&:id) | |
=> [2, 1, 3, 4, 5] | |
[19] pry(main)> ids.each do |id| | |
[19] pry(main)* @users = User.where(id: id) rescue User.where(id: id) | |
[19] pry(main)* end | |
=> [2, 1, 3, 4, 5] | |
Why doesn't this return all of the instances of User? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment