Re: has_one :through eager-loading problem

eleasar
Tue, 16 Sep 2008 16:51:42 -0000

Thank you!

On 16 Sep., 18:45, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> On 16 Sep 2008, at 17:35, eleasar wrote:
>
>
>
> > 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
>
> > 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..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com