Skip to content
Browse files

Merge pull request #14140 from WojtekKruszewski/optimize_foreign_key_for

Prevent foreign_key_for? from evaluating all attributes
  • Loading branch information...
2 parents b1867c8 + dbf9ec0 commit 467cb908dd5f40cbfefe41b93e219682a3ced535 @carlosantoniodasilva carlosantoniodasilva committed Feb 21, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/associations/association.rb
2 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)
# This should be implemented to return the values of the relevant key(s) on the owner,

0 comments on commit 467cb90

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