Creating reflective has_and_belongs_to

Hi I have a question is it possible to create the reflective relation
with users and friends using has_and_belongs_to. I found this post that
is partly connected to my:

but my issue is join table “friends_users” where I would need to create
duplication of data when the relationship is reflective: every time
someone create the friend I need to add two rows to the join table
(user, friend) and (friend, user) with just swapped ids. Is there any
better way of handling this type of relations?

Piotr J. Puczyński

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs