# has\_one :through eager-loading problem

**URL:** <https://discuss.rubyonrails.org/t/has-one-through-eager-loading-problem/34398>\
**Category:** rubyonrails-talk\
**Created:** [September 16, 2008, 4:35pm UTC](https://discuss.rubyonrails.org/t/has-one-through-eager-loading-problem/34398 "2008-09-16T16:35:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eleasar](https://avatars.discourse-cdn.com/v4/letter/e/a587f6/32.png) [@eleasar](https://discuss.rubyonrails.org/u/eleasar)\
**Post date:** [September 16, 2008, 4:35pm UTC](https://discuss.rubyonrails.org/t/has-one-through-eager-loading-problem/34398/1 "2008-09-16T16:35:30Z")

</div>

I have a problem with the :include option in find for my has\_one :through association.

I have Users, Profiles and Customers, all connected to each other with a has\_one :through =\> :membership association like this:

class Profile \< ActiveRecord::Base #could also be user or customer

&nbsp;&nbsp;has\_one :membership # i saw an acrticle of Ryan about has\_one :through, there this would be has\_many, is this wrong? &nbsp;&nbsp;has\_one :user, :through =\> :membership &nbsp;&nbsp;has\_one :customer, :through =\> :membership

end

now if I search for profiles with the :include option:

def index &nbsp;&nbsp;@profiles = User.find(:all, :include =\> [:user, :customer]) end

i get an error:

Mysql::Error: #42S22Unknown column 'users.profile\_id' in 'on clause'

obviously, it searches for the profile\_id on the wrong place, it should search it in memberships

anyone has an idea? Thanks..

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [September 16, 2008, 4:45pm UTC](https://discuss.rubyonrails.org/t/has-one-through-eager-loading-problem/34398/2 "2008-09-16T16:45:55Z")

</div>

> I have a problem with the :include option in find for my has\_one :through association.
> 
> I have Users, Profiles and Customers, all connected to each other with a has\_one :through =\> :membership association like this:

:including of has\_one :through is basically just broken on rails 2.1.  
It's fixed on edge.

Fred

---

<div class="post-metadata">

**Author:** ![eleasar](https://avatars.discourse-cdn.com/v4/letter/e/a587f6/32.png) [@eleasar](https://discuss.rubyonrails.org/u/eleasar)\
**Post date:** [September 16, 2008, 4:51pm UTC](https://discuss.rubyonrails.org/t/has-one-through-eager-loading-problem/34398/3 "2008-09-16T16:51:42Z")

</div>

Thank you!
