2 models with name scope:
class A
scope :active, where(“active = ?”, true)
end
class B
scope :active, where(“active = ?”, true)
end
In my console:
A.active and B.active individual i get the correct records. So this works fine.
Now i want to join the 2 scopes in one query with the & sign, like this:
A.active & B.active
The result is no error but the dataset is empty!
Of course it is – & is Array intersection, and as A.active contains only As and B.active only Bs, the intersection will always be empty. Maybe you just want concatenation?
see
http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-26
and
http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-2B