# Comments belonging to two different models

**URL:** <https://www.ruby-forum.com/t/comments-belonging-to-two-different-models/171143>\
**Category:** Rails\
**Created:** [June 26, 2009, 11:40pm UTC](https://www.ruby-forum.com/t/comments-belonging-to-two-different-models/171143 "2009-06-26T23:40:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toushi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@Toushi](https://www.ruby-forum.com/u/Toushi)\
**Post date:** [June 26, 2009, 11:40pm UTC](https://www.ruby-forum.com/t/comments-belonging-to-two-different-models/171143/1 "2009-06-26T23:40:53Z")

</div>

Hello,  
I am building a project management application, and I want my clients  
to be able to comment on multiple things.  
For instance I have 2 models: milestones, and tickets, I have the  
foreign keys for both of them in the comments model and linked them  
with has\_many and belongs\_to. I am just wondering if this is possible?  
Or if there is a better way to do it.

Thanks,  
Ben.

---

<div class="post-metadata">

**Author:** ![Toushi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/91b2a8/32.png) [@Toushi](https://www.ruby-forum.com/u/Toushi)\
**Post date:** [June 27, 2009, 12:19am UTC](https://www.ruby-forum.com/t/comments-belonging-to-two-different-models/171143/2 "2009-06-27T00:19:31Z")

</div>

What you really need is polymorphic associations.

But you can also just get a plugin with the code already implemented -

> **[GitHub - jackdempsey/acts\_as\_commentable: The ActiveRecord acts\_as\_commentable...](https://github.com/jackdempsey/acts_as_commentable/tree/master)**
>
> master

- 

Maurício Linhares  
[http://codeshooter.wordpress.com/](http://codeshooter.wordpress.com/) | [http://twitter.com/mauriciojr](http://twitter.com/mauriciojr)
