aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-14 15:08:03 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-14 15:08:08 -0700
commit9a21774d73ebb1eece5ef29d71de17147be99992 (patch)
tree77dcfd549ac1e804a26d7f7fd1a9627affec4a07
parentaa31d21f5f4fc4d679e74a60f9df9706da7de373 (diff)
downloadrails-9a21774d73ebb1eece5ef29d71de17147be99992.tar.gz
rails-9a21774d73ebb1eece5ef29d71de17147be99992.tar.bz2
rails-9a21774d73ebb1eece5ef29d71de17147be99992.zip
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.
-rw-r--r--activerecord/lib/active_record/persistence.rb10
1 files changed, 1 insertions, 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)