mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Singular associations no longer use a proxy, so no need to check for the proxy type on assignment.
This commit is contained in:
committed by
Aaron Patterson
parent
1d85a73ceb
commit
73ff0076b3
@@ -3,7 +3,7 @@ module ActiveRecord
|
||||
module Associations
|
||||
class BelongsToAssociation < SingularAssociation #:nodoc:
|
||||
def replace(record)
|
||||
record = check_record(record)
|
||||
raise_on_type_mismatch(record) if record
|
||||
|
||||
update_counters(record)
|
||||
replace_keys(record)
|
||||
|
||||
@@ -3,7 +3,7 @@ module ActiveRecord
|
||||
module Associations
|
||||
class HasOneAssociation < SingularAssociation #:nodoc:
|
||||
def replace(record, save = true)
|
||||
record = check_record(record)
|
||||
raise_on_type_mismatch(record) if record
|
||||
load_target
|
||||
|
||||
reflection.klass.transaction do
|
||||
|
||||
@@ -28,12 +28,6 @@ module ActiveRecord
|
||||
replace(record)
|
||||
end
|
||||
|
||||
def check_record(record)
|
||||
record = record.target if Association === record
|
||||
raise_on_type_mismatch(record) if record
|
||||
record
|
||||
end
|
||||
|
||||
def new_record(method, attributes)
|
||||
attributes = scoped.scope_for_create.merge(attributes || {})
|
||||
record = reflection.send("#{method}_association", attributes)
|
||||
|
||||
Reference in New Issue
Block a user