diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 13dd374f9c738..e88a8304b52cd 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -618,7 +618,7 @@ def ==(comparison_object) def hash id = self.id - if primary_key_values_present? + if self.class.composite_primary_key? ? primary_key_values_present? : id self.class.hash ^ id.hash else super