Skip to content

Instantly share code, notes, and snippets.

@DBA
Created July 30, 2010 10:38
Show Gist options
  • Save DBA/500294 to your computer and use it in GitHub Desktop.
Save DBA/500294 to your computer and use it in GitHub Desktop.
module ActiveRecordAttributesEquality
def self.included(klass)
klass.class_eval do
def ==(other)
return false unless other.is_a? self.class
if self.new_record? && other.new_record?
self.attributes == other.attributes
else
super(other)
end
end
end
end # included
end # ActiveRecordAttributesEquality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment