Skip to content

Commit

Permalink
Merge pull request #14140 from WojtekKruszewski/optimize_foreign_key_for
Browse files Browse the repository at this point in the history
Prevent foreign_key_for? from evaluating all attributes
  • Loading branch information
carlosantoniodasilva committed Feb 21, 2014
1 parent d094d7e commit 2fdbddd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/associations/association.rb
Expand Up @@ -232,7 +232,7 @@ def invertible_for?(record)


# Returns true if record contains the foreign_key # Returns true if record contains the foreign_key
def foreign_key_for?(record) def foreign_key_for?(record)
record.attributes.has_key? reflection.foreign_key record.has_attribute?(reflection.foreign_key)
end end


# This should be implemented to return the values of the relevant key(s) on the owner, # This should be implemented to return the values of the relevant key(s) on the owner,
Expand Down

0 comments on commit 2fdbddd

Please sign in to comment.