How about a little trick. Make Id column of the table a string and
then:
class Friendship < ActiveRecord::Base
belongs_to :sender, ...
belongs_to :requester, ...
before_validation :standarize_id, :on => :create
validates_uniqueness_of :id
def standarize_id
self.id = [sender.id, requester.id].sort.join(",")
end
end
This way we don't forget the information about whose is the sender and
who is requester. Instead we relay on standarized unique id for the
the couple.
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.