From df73d696f5a965b67c9f177bf4dd8d85921d0214 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Wed, 14 Jan 2015 15:25:15 -0700 Subject: Go through normal where logic in destroy with locking 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/locking/optimistic.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index aeb1a4ddc6..6f2b65c137 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -125,12 +125,8 @@ module ActiveRecord relation = super if locking_enabled? - column_name = self.class.locking_column - column = self.class.columns_hash[column_name] - substitute = self.class.connection.substitute_at(column) - - relation = relation.where(self.class.arel_table[column_name].eq(substitute)) - relation.bind_values << [column, self[column_name].to_i] + locking_column = self.class.locking_column + relation = relation.where(locking_column => _read_attribute(locking_column)) end relation -- cgit v1.2.3