# Has\_one :through eager-loading problem

**URL:** <https://www.ruby-forum.com/t/has-one-through-eager-loading-problem/148736>\
**Category:** Rails\
**Created:** [September 16, 2008, 6:45pm UTC](https://www.ruby-forum.com/t/has-one-through-eager-loading-problem/148736 "2008-09-16T18:45:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wurdalag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/6f9a4e/32.png) [@wurdalag](https://www.ruby-forum.com/u/wurdalag)\
**Post date:** [September 16, 2008, 6:45pm UTC](https://www.ruby-forum.com/t/has-one-through-eager-loading-problem/148736/1 "2008-09-16T18:45:33Z")

</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

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

end

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

def index  
@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…
