We have been using the default scopes pretty extensively to achieve
multi tenancy and have used dynamic default scopes (modifying the
Thread.current[:Model_scoped_methods] directly) and overall have had
great success with this approach.
We recently came across a bug where the delete_all uses the default
scope :conditions but not the :joins which causes SQL errors. I
haven't looked through the source to create a failing test case or
verify this assumption but we found a very similar bug on lighthouse
This bug was marked as won't fix as it was deemed that update_all (and
I'm guessing delete_all) should deal only with raw SQL. However in
our case the delete_all is taking :conditions but not the :joins and
it seems it should either take all the scopes or none at all.
I personally would like to see the :joins be taken into account,
however, this is a contradictory view to the general consensus in
lighthouse. I don't want to create a patch and test case if it's
going to be rejected.
I'm wondering what other's thoughts are in terms of whether this is a
bug, expected behaviour, and what the next steps are. ie. Remove
the :conditions from the delete_all or add the :joins to the
delete_all / update_all.