# Has\_many and has\_and\_belongs\_to conflit

**URL:** <https://www.ruby-forum.com/t/has-many-and-has-and-belongs-to-conflit/189399>\
**Category:** Rails\
**Created:** [May 31, 2010, 9:49am UTC](https://www.ruby-forum.com/t/has-many-and-has-and-belongs-to-conflit/189399 "2010-05-31T09:49:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [May 31, 2010, 9:49am UTC](https://www.ruby-forum.com/t/has-many-and-has-and-belongs-to-conflit/189399/1 "2010-05-31T09:49:43Z")

</div>

Hi,

I have 2 models: User and Article.

I have this relationship:

- User has many articles (and Article belongs to user)
- User has and belongs to many articles (and Article habtm users)

But this is tricky because of: current\_user.articles …this can return  
articles thanks to _has\_many_ and _has\_and\_belongs\_to_ relations. So  
there’s a collision.

How can I ask articles thanks has\_and\_belongs\_to explicitly. And thanks  
has\_many only too?

Thanks

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [May 31, 2010, 10:34am UTC](https://www.ruby-forum.com/t/has-many-and-has-and-belongs-to-conflit/189399/2 "2010-05-31T10:34:07Z")

</div>

On May 31, 8:49 am, “David B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,

> But this is tricky because of: current\_user.articles …this can return  
> articles thanks to _has\_many_ and _has\_and\_belongs\_to_ relations. So  
> there’s a collision.
> 
> How can I ask articles thanks has\_and\_belongs\_to explicitly. And thanks  
> has\_many only too?

Call one of the relationships something else, eg  
has\_many :something\_articles, :class\_name =\> “Article”

Fred

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [May 31, 2010, 11:39am UTC](https://www.ruby-forum.com/t/has-many-and-has-and-belongs-to-conflit/189399/3 "2010-05-31T11:39:34Z")

</div>

Frederick C. wrote:

> On May 31, 8:49ï¿½am, “David B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> Call one of the relationships something else, eg  
> has\_many :something\_articles, :class\_name =\> “Article”
> 
> Fred

Thank you Fred
