On Sep 5, 12:09 pm, Greg H. [email protected]
2009/9/5 Frederick C. [email protected]:
Compare their attributes ?
Guess I was looking for an automated way to do this if one existed?
or is there some concept of having to implement some basic comparison
class in Ruby & then being able to have the “==” method work?
Classes can implement their own == method. ActiveRecord::Base does do
this, just not the way you want it too - ActiveRecord considers two
objects to be equal if they correspond to the same row in the database
(ie have the same id). If you have two unsaved objects then saving
them would yield two different rows in the database, therefore by AR’s
reckoning they are not equal. While you could override == on your
class that may well break bits of ActiveRecord that expects == to
behave in a certain way.