How to get not exists set in collection in Rails -
i wanna set doesn't exists in collection. following:
ids = [1,2,3,4,5] # 2,3,4 not exists user.where(:id => ids)
i want set [2,3,4]
without affecting performance,have solution?
use following:
ids - user.where(id: ids).select(:id).map(&:id)
Comments
Post a Comment