Permalink
Browse files

Merge pull request #14140 from WojtekKruszewski/optimize_foreign_key_for

Prevent foreign_key_for? from evaluating all attributes
  • Loading branch information...
1 parent 20f475c commit f214896ab9a62dd948b43751cebc77541eb7c2b1 @carlosantoniodasilva carlosantoniodasilva committed Feb 21, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/associations/association.rb
@@ -240,7 +240,7 @@ def invertible_for?(record)
# Returns true if record contains the foreign_key
def foreign_key_for?(record)
- record.attributes.has_key? reflection.foreign_key
+ record.has_attribute?(reflection.foreign_key)
end
# This should be implemented to return the values of the relevant key(s) on the owner,

0 comments on commit f214896

Please sign in to comment.