aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-19 16:59:30 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-19 16:59:30 +0000
commit3140e37d18c66527a80a153727a7ea972b80506a (patch)
treec6684dc22853dc1188cdd057f92cd46126ec50a3 /activerecord/lib
parent77af61be40256d1e9e238d093bbd1ffb95263c67 (diff)
downloadrails-3140e37d18c66527a80a153727a7ea972b80506a.tar.gz
rails-3140e37d18c66527a80a153727a7ea972b80506a.tar.bz2
rails-3140e37d18c66527a80a153727a7ea972b80506a.zip
Dont reload on empty associations
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1231 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 017689b9cd..e447da3051 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -702,16 +702,18 @@ module ActiveRecord
record = records[id]
reflections.each do |reflection|
- next unless row[primary_key_table[reflection.table_name]]
-
case reflection.macro
when :has_many, :has_and_belongs_to_many
collection = record.send(reflection.name)
collection.loaded
+ next unless row[primary_key_table[reflection.table_name]]
+
association = reflection.klass.send(:instantiate, extract_record(schema_abbreviations, reflection.table_name, row))
collection.target.push(association) unless collection.target.include?(association)
when :has_one, :belongs_to
+ next unless row[primary_key_table[reflection.table_name]]
+
record.send(
"#{reflection.name}=",
reflection.klass.send(:instantiate, extract_record(schema_abbreviations, reflection.table_name, row))