From 9a21774d73ebb1eece5ef29d71de17147be99992 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Wed, 14 Jan 2015 15:08:03 -0700 Subject: [PATCH] Go through normal where logic in destroy Building the Arel AST, and manipulating the relation manually like this is prone to errors and breakage as implementation details change from underneath it. --- activerecord/lib/active_record/persistence.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index cf6673db2e..6306a25745 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -495,15 +495,7 @@ module ActiveRecord end def relation_for_destroy - pk = self.class.primary_key - column = self.class.columns_hash[pk] - substitute = self.class.connection.substitute_at(column) - - relation = self.class.unscoped.where( - self.class.arel_table[pk].eq(substitute)) - - relation.bind_values = [[column, id]] - relation + self.class.unscoped.where(self.class.primary_key => id) end def create_or_update(*args)