Anyone has any thoughts on this please?
On Apr 8, 5:29 pm, Moo <janec...@gmail.com> wrote:
> Hi Everyone,
>
> I'm running into a problem with the ActiveRecord::Base "==" method
> defined here (it's 2.3.2, but it looks the same in older versions
> too):
>
> # File rails-2.3.2/activerecord/lib/active_record/base.rb, line
> 2816
> 2816: def ==(comparison_object)
> 2817: comparison_object.equal?(self) ||
> 2818: (comparison_object.instance_of?(self.class) &&
> 2819: comparison_object.id == id &&
> 2820: !comparison_object.new_record?)
> 2821: end
>
> Because of the last criteria (!comparison_object.new_record?),
> something like this happens... say i have a new record and an existing
> record (different objects) and compare them:
>
> > new == old
> => true
> > old == new
>
> => false
>
> If this is intentional, can someone please explain why this is?
>
> Also what is the rational of only comparing the ID and not the all the
> values too and why does it matter if it's a new record or not?
>
> Thank you!
> -Moo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---