mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use _relation_for_itself
wherever possible
Anywhere that we're doing `self.class.unscoped.where(primary_key => id)` is somewhere that someone may want to extend. Even if this method isn't public API yet, this will make it easier for us to eventually expose an API around this. Plus, duplicated code makes me sad.
This commit is contained in:
parent
6f9b01c056
commit
6be22632b1
1 changed files with 2 additions and 3 deletions
|
@ -332,7 +332,7 @@ module ActiveRecord
|
|||
verify_readonly_attribute(key.to_s)
|
||||
end
|
||||
|
||||
updated_count = self.class.unscoped.where(self.class.primary_key => id).update_all(attributes)
|
||||
updated_count = _relation_for_itself.update_all(attributes)
|
||||
|
||||
attributes.each do |k, v|
|
||||
write_attribute_without_type_cast(k, v)
|
||||
|
@ -523,8 +523,7 @@ module ActiveRecord
|
|||
changes[column] = write_attribute(column, time)
|
||||
end
|
||||
|
||||
primary_key = self.class.primary_key
|
||||
scope = self.class.unscoped.where(primary_key => _read_attribute(primary_key))
|
||||
scope = _relation_for_itself
|
||||
|
||||
if locking_enabled?
|
||||
locking_column = self.class.locking_column
|
||||
|
|
Loading…
Reference in a new issue