File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -17,21 +17,26 @@ module Persistence
1717 # that no changes should be made (since they can't be persisted).
1818 def destroy
1919 destroy_associations
20-
20+
2121 if persisted?
2222 IdentityMap . remove ( self ) if IdentityMap . enabled?
2323 pk = self . class . primary_key
2424 column = self . class . columns_hash [ pk ]
2525 substitute = connection . substitute_at ( column , 0 )
26-
27- using_arel_table = self . respond_to? ( :dynamic_arel_table ) ? dynamic_arel_table ( ) : self . class . arel_table
28- relation = self . class . unscoped . where (
29- using_arel_table [ pk ] . eq ( substitute ) )
30-
26+
27+ if self . class . respond_to? ( :dynamic_arel_table )
28+ using_arel_table = dynamic_arel_table ( )
29+ relation = ActiveRecord ::Relation . new ( self . class , using_arel_table ) .
30+ where ( using_arel_table [ pk ] . eq ( substitute ) )
31+ else
32+ using_arel_table = self . class . arel_table
33+ relation = self . class . unscoped . where ( using_arel_table [ pk ] . eq ( substitute ) )
34+ end
35+
3136 relation . bind_values = [ [ column , id ] ]
3237 relation . delete_all
3338 end
34-
39+
3540 @destroyed = true
3641 freeze
3742 end
You can’t perform that action at this time.
0 commit comments