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 d094d7e commit 2fdbdddbc0850d11f59d5fbfa6edc611924befd6 @carlosantoniodasilva carlosantoniodasilva committed Feb 21, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/associations/association.rb
@@ -232,7 +232,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 2fdbddd

Please sign in to comment.