diff options
Diffstat (limited to 'activerecord/lib')
3 files changed, 2 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb index d6c107bf9f..c1471c72df 100644 --- a/activerecord/lib/active_record/associations/belongs_to_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_association.rb @@ -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) diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index 9b51abc93b..bff537d3c5 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -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 diff --git a/activerecord/lib/active_record/associations/singular_association.rb b/activerecord/lib/active_record/associations/singular_association.rb index b970ad7a67..e75fdaf36f 100644 --- a/activerecord/lib/active_record/associations/singular_association.rb +++ b/activerecord/lib/active_record/associations/singular_association.rb @@ -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) |