# Has\_many :through, expects "through" model to be belongs\_to

**URL:** <https://www.ruby-forum.com/t/has-many-through-expects-through-model-to-be-belongs-to/161640>\
**Category:** Rails I18n\
**Created:** [February 28, 2009, 7:20am UTC](https://www.ruby-forum.com/t/has-many-through-expects-through-model-to-be-belongs-to/161640 "2009-02-28T07:20:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![preethi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f04885/32.png) [@preethi](https://www.ruby-forum.com/u/preethi)\
**Post date:** [February 28, 2009, 7:20am UTC](https://www.ruby-forum.com/t/has-many-through-expects-through-model-to-be-belongs-to/161640/1 "2009-02-28T07:20:46Z")

</div>

## Hi, I’m using has\_many and through relationship between two models Profile and User Profile.rb

has\_and\_belongs\_to\_many :users  
belongs\_to :community

## User.rb

has\_and\_belongs\_to\_many :profiles  
has\_many :communities, :through=\>profiles

When i try to do  
@user.communities, Rails is searching for foreign key of user in profile  
table, whereas profile and user have habtm relationship.  
How to solve this problem?  
Its urgent. please help
