aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-05 17:08:56 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-05 17:08:56 -0700
commit39a80567918af298b39898d78062e7a8fb5da601 (patch)
tree8ba14b39983ef95e1db600b3d6670727efe9831d /activerecord
parentc43d909ee28484c5e7d7d84b1228e10212d20737 (diff)
downloadrails-39a80567918af298b39898d78062e7a8fb5da601.tar.gz
rails-39a80567918af298b39898d78062e7a8fb5da601.tar.bz2
rails-39a80567918af298b39898d78062e7a8fb5da601.zip
only call to_s on the association variable once
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 0fc8740dce..8d415cdfdf 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1983,10 +1983,13 @@ module ActiveRecord
def construct(parent, associations, join_parts, row)
case associations
when Symbol, String
+ associations = associations.to_s
+
join_part = join_parts.detect { |j|
- j.reflection.name.to_s == associations.to_s &&
+ j.reflection.name.to_s == associations &&
j.parent_table_name == parent.class.table_name }
- raise(ConfigurationError, "No such association") if join_part.nil?
+
+ raise(ConfigurationError, "No such association") unless join_part
join_parts.delete(join_part)
construct_association(parent, join_part, row)