# HABTM and REST

**URL:** <https://www.ruby-forum.com/t/habtm-and-rest/119320>\
**Category:** Rails\
**Created:** [November 6, 2007, 12:23am UTC](https://www.ruby-forum.com/t/habtm-and-rest/119320 "2007-11-06T00:23:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [November 6, 2007, 12:23am UTC](https://www.ruby-forum.com/t/habtm-and-rest/119320/1 "2007-11-06T00:23:35Z")

</div>

I have found a few places that have said that they don’t mix well, but I  
haven’t been able to find any reasoning as to why.

Does anyone have any knowledge to why this is?

Thanks

---

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [November 6, 2007, 8:21am UTC](https://www.ruby-forum.com/t/habtm-and-rest/119320/2 "2007-11-06T08:21:07Z")

</div>

Chris O. wrote:

> I have found a few places that have said that they don’t mix well, but I  
> haven’t been able to find any reasoning as to why.
> 
> Does anyone have any knowledge to why this is?

It’s not that they don’t mix well - it’s fine to use habtm with RESTful  
resources. It’s that you don’t get any synergy from using both of them  
together, since you can’t use a habtm join table record as a resource  
that can be addressed with a RESTful URL. But with has\_many :through, a  
URL can describe a join model record as a resource. That means you have  
a noun that you can manipulate with the standard HTTP verbs. With habtm,  
you have to invent custom actions to manipulate the joins, so it’s not  
as easy or compatible. That’s all.

–  
Josh S.  
[http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)

---

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [November 6, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/habtm-and-rest/119320/3 "2007-11-06T15:30:08Z")

</div>

Josh S. wrote:

> It’s not that they don’t mix well - it’s fine to use habtm with RESTful  
> resources. It’s that you don’t get any synergy from using both of them  
> together, since you can’t use a habtm join table record as a resource  
> that can be addressed with a RESTful URL. But with has\_many :through, a  
> URL can describe a join model record as a resource. That means you have  
> a noun that you can manipulate with the standard HTTP verbs. With habtm,  
> you have to invent custom actions to manipulate the joins, so it’s not  
> as easy or compatible. That’s all.
> 
> –  
> Josh S.  
> [http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)

Thanks Josh, that makes sense.
