提交 df73d696 编写于 作者: S Sean Griffin

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.
上级 9a21774d
......@@ -125,12 +125,8 @@ def relation_for_destroy
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册