diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-02-20 20:34:06 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-21 10:16:14 -0800 |
commit | 73ff0076b37316af685bc411bd11a7908d7794f6 (patch) | |
tree | 2e1d43ae28bd7926ed811a5df50659e5c283dc92 /activerecord/lib/active_record | |
parent | 1d85a73cebeea26a3ec384db1c110f6b79d9cda2 (diff) | |
download | rails-73ff0076b37316af685bc411bd11a7908d7794f6.tar.gz rails-73ff0076b37316af685bc411bd11a7908d7794f6.tar.bz2 rails-73ff0076b37316af685bc411bd11a7908d7794f6.zip |
Singular associations no longer use a proxy, so no need to check for the proxy type on assignment.
Diffstat (limited to 'activerecord/lib/active_record')
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) |