How to return an empty ActiveRecord relation?

If I have a scope with a lambda and it takes an argument, depending on the value of the argument, I might know that there will not be any matches, but I still want to return a relation, not an empty array: scope :for_users, lambda { |users| users.any? ? where(“user_id IN (?)”, users.map(&:id).join(‘,’)) : [] … Read more