File tree 1 file changed +6
-2
lines changed
lib/activerecord-multi-tenant
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ module Arel
4
4
module ActiveRecordRelationExtension
5
5
# Overrides the delete_all method to include tenant scoping
6
6
def delete_all
7
+ model = MultiTenant . multi_tenant_model_for_arel ( arel )
8
+
7
9
# Call the original delete_all method if the current tenant is identified by an ID
8
- return super if MultiTenant . current_tenant_is_id? || MultiTenant . current_tenant . nil?
10
+ return super if model . nil? || MultiTenant . current_tenant_is_id? || MultiTenant . current_tenant . nil?
9
11
10
12
stmt = Arel ::DeleteManager . new . from ( table )
11
13
stmt . wheres = [ generate_in_condition_subquery ]
@@ -16,8 +18,10 @@ def delete_all
16
18
17
19
# Overrides the update_all method to include tenant scoping
18
20
def update_all ( updates )
21
+ model = MultiTenant . multi_tenant_model_for_arel ( arel )
22
+
19
23
# Call the original update_all method if the current tenant is identified by an ID
20
- return super if MultiTenant . current_tenant_is_id? || MultiTenant . current_tenant . nil?
24
+ return super if model . nil? || MultiTenant . current_tenant_is_id? || MultiTenant . current_tenant . nil?
21
25
22
26
stmt = Arel ::UpdateManager . new
23
27
stmt . table ( table )
You can’t perform that action at this time.
0 commit comments