I've got a polymorphic association on one table. I assign to it in the
This is handling invitations of users to tasks in a task management
application. If the user issuing the invitation is the user being
invited (ie the user assigned themselves to a task), I want to
activate the invitation immediately in the model.
The trouble is that this:
if self.assignable == self.created_by
self.activated_at = Time.now
self.activation_code = nil
fails to detect equality correctly. I've tried ===, eql? etc.
When I look at .__id__ when I know that I set assignable equal to
created_by, the values are different (wildly so; one is like 4 and the
other is a five digit number or something).
I'm guessing Rails handles polymorphic associations via a proxy object
or something. So the question is: how do I do this comparison?