Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

extract exception raising, clean up group_by statement

  • Loading branch information...
commit 8f9bba7058c5ff376c7fbcd0f2d5561758085b8e 1 parent 7ad26e8
@tenderlove tenderlove authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 activerecord/lib/active_record/associations/preloader.rb
View
13 activerecord/lib/active_record/associations/preloader.rb
@@ -147,15 +147,16 @@ def records_by_reflection(association)
records.group_by do |record|
reflection = record.class.reflect_on_association(association)
- unless reflection
- raise ActiveRecord::ConfigurationError, "Association named '#{association}' was not found; " \
- "perhaps you misspelled it?"
- end
-
- reflection
+ reflection || raise_config_error(association)
end
end
+ def raise_config_error(association)
+ raise ActiveRecord::ConfigurationError,
+ "Association named '#{association}' was not found; " \
+ "perhaps you misspelled it?"
+ end
+
def association_klass(reflection, record)
if reflection.macro == :belongs_to && reflection.options[:polymorphic]
klass = record.send(reflection.foreign_type)

0 comments on commit 8f9bba7

Please sign in to comment.
Something went wrong with that request. Please try again.