# HABTM Question

**URL:** <https://www.ruby-forum.com/t/habtm-question/147450>\
**Category:** Rails\
**Created:** [September 1, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/habtm-question/147450 "2008-09-01T23:10:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![starnix17](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@starnix17](https://www.ruby-forum.com/u/starnix17)\
**Post date:** [September 1, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/habtm-question/147450/1 "2008-09-01T23:10:52Z")

</div>

OK, I’m working on a simple site to share music created by users from  
a forum I belong to. I’m trying to make it so users can follow other  
users to keep track of what they’re up to (sort of like Twitter if you  
know how that works).

Currently I’m working on the page that displays the users that follow  
a certain user, I can easily do the reverse of this (see what users a  
certain user is follow, user.friends) but I can’t do it the other way.

Does Rails have a built-in method for this (I’ve searched the API  
docs, and the Agile Web Dev book with no luck)?

Thanks,  
Tony

---

<div class="post-metadata">

**Author:** ![starnix17](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@starnix17](https://www.ruby-forum.com/u/starnix17)\
**Post date:** [September 1, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/habtm-question/147450/2 "2008-09-01T23:35:28Z")

</div>

On Sep 1, 10:10 pm, TeeC [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> OK, I’m working on a simple site to share music created by users from  
> a forum I belong to. I’m trying to make it so users can follow other  
> users to keep track of what they’re up to (sort of like Twitter if you  
> know how that works).
> 
> Currently I’m working on the page that displays the users that follow  
> a certain user, I can easily do the reverse of this (see what users a  
> certain user is follow, user.friends) but I can’t do it the other way.

Don’t you just create another habtm which uses the same join table but  
with the :foreign\_key and :associated\_foreign\_key options swapped  
round ?

Fred

---

<div class="post-metadata">

**Author:** ![starnix17](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@starnix17](https://www.ruby-forum.com/u/starnix17)\
**Post date:** [September 1, 2008, 11:59pm UTC](https://www.ruby-forum.com/t/habtm-question/147450/3 "2008-09-01T23:59:27Z")

</div>

Wow, that was surprisingly simple.

Thanks,  
Tony

On Sep 1, 5:34 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
