# Creating reflective has\_and\_belongs\_to

**URL:** <https://www.ruby-forum.com/t/creating-reflective-has-and-belongs-to/191909>\
**Category:** Rails\
**Created:** [July 20, 2010, 3:53pm UTC](https://www.ruby-forum.com/t/creating-reflective-has-and-belongs-to/191909 "2010-07-20T15:53:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piotr\_Jacek\_Puczyns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@Piotr\_Jacek\_Puczyns](https://www.ruby-forum.com/u/Piotr_Jacek_Puczyns)\
**Post date:** [July 20, 2010, 3:53pm UTC](https://www.ruby-forum.com/t/creating-reflective-has-and-belongs-to/191909/1 "2010-07-20T15:53:48Z")

</div>

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:  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/dff2032301961e2d](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/dff2032301961e2d)

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
