mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
aa31d21f5f
commit
9a21774d73
1 changed files with 1 additions and 9 deletions
|
@ -495,15 +495,7 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def relation_for_destroy
|
def relation_for_destroy
|
||||||
pk = self.class.primary_key
|
self.class.unscoped.where(self.class.primary_key => id)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_or_update(*args)
|
def create_or_update(*args)
|
||||||
|
|
Loading…
Reference in a new issue