Hi Robert! Thanks for the post.

Your thought would work, except that it's very much like 'friendship'
in that it's immaterial who requested the 'friendship'. And that's the
crux of it. Since Person 1 or Person 2 could be the sender/requester,
it has to check both ways.

Then again, I just had a thought. Perhaps given two people, the lower
ID is always set as the sender and the other as the receiver. Hmmm...
then, the order would always be known.

If Person 2 requests friendship with Person 1, the friendship object
is saved with sender=>1, receiver=>2
Then, if later Person 1 requests friendship with Person 2, it's saved
as sender=>1, receiver=>2 and it would fail validation.

Interesting... I need to noodle on that a bit more and see if that
would work thoroughly.

Thanks!

-Danimal

On Mar 11, 5:08 am, "Robert Pankowecki (rupert)"
<robert.pankowe...@gmail.com> wrote:
> You could alway store them in known order so that
> sender.id <= reciver.id
> and use scoped validates_uniqueness_of.
>
> Assuming that sender and reciver can be exchanged in this relationship
> and does not have any additional meaning.
>
> Like 'friendship' when it does not matter who is friend A and who is
> friend B
>
> Robert Pankowecki

-- 
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.

Reply via email to