Permalink
Browse files

Extract local variable to avoid method call

  • Loading branch information...
rafaelfranca committed Oct 13, 2013
1 parent 603d553 commit cfbd4a493e747e0b97052f30319fb57e870069e5
Showing with 3 additions and 2 deletions.
  1. +3 −2 activerecord/lib/active_record/associations/preloader.rb
@@ -141,10 +141,11 @@ def grouped_records(association)
def records_by_reflection(association)
records.group_by do |record|
- reflection = record.class.reflections[association]
+ record_class = record.class
+ reflection = record_class.reflections[association]
unless reflection
- raise ActiveRecord::ConfigurationError, "Association named '#{association}' was not found on #{record.class.name}; " \
+ raise ActiveRecord::ConfigurationError, "Association named '#{association}' was not found on #{record_class.name}; " \
"perhaps you misspelled it?"
end

0 comments on commit cfbd4a4

Please sign in to comment.