users collection1 minus users collection2
I am using Rails 3.0.8
Lets say that I have two collections of users.
users1 = User.where(....)
users2 = User.where(....)
I need
users1 - users2
One way to get the solution is
ids开发者_如何学编程 = users1.map(&:id) - users2.map(&:id)
ids.map{ |i| User.find(i) }
Above code will work. However I was wondering if ActiveRecord implements some kind of equality operator so that I do not have to get ids from that collection.
users1 - users2
works perfectly, keep it simple!
精彩评论