Edit / Solution
As mentioned in the comments above, and as @ahmacleod pointed out, allthis is what we are looking for
scope :closest, ->(point) {
point.nil? ? all : where(point: point)
}
End editing
I think I found what I'm looking for, and unscoped
scope :closest, ->(point) {
point.nil? ? unscoped : where(point: point)
}
The problem is that if I connect this, I would lose the previous areas if I use them after them.
source
share