aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-06 18:20:02 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-06 18:20:08 -0700
commit1acc086278c974d7a3cdb0459cd65f73641abe33 (patch)
tree7615dc447a48aeccda7fb691e500f5f932a94f95 /activerecord
parent46332e458cc89ca9166099ad7609a4d65a12e48d (diff)
downloadrails-1acc086278c974d7a3cdb0459cd65f73641abe33.tar.gz
rails-1acc086278c974d7a3cdb0459cd65f73641abe33.tar.bz2
rails-1acc086278c974d7a3cdb0459cd65f73641abe33.zip
reduce duplication in assiciations #construct()
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index aad0cbb895..c84673e6a6 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1983,10 +1983,10 @@ module ActiveRecord
def construct(parent, associations, join_parts, row)
case associations
when Symbol, String
- associations = associations.to_s
+ name = associations.to_s
join_part = join_parts.detect { |j|
- j.reflection.name.to_s == associations &&
+ j.reflection.name.to_s == name &&
j.parent_table_name == parent.class.table_name }
raise(ConfigurationError, "No such association") unless join_part
@@ -1999,13 +1999,7 @@ module ActiveRecord
end
when Hash
associations.sort_by { |k,_| k.to_s }.each do |name, assoc|
- join_part = join_parts.detect{ |j|
- j.reflection.name.to_s == name.to_s &&
- j.parent_table_name == parent.class.table_name }
- raise(ConfigurationError, "No such association") if join_part.nil?
-
- association = construct_association(parent, join_part, row)
- join_parts.delete(join_part)
+ association = construct(parent, name, join_parts, row)
construct(association, assoc, join_parts, row) if association
end
else