Another newbie question. My dummy app has the following models:

class User < ActiveRecord::Base
  has_one :list
end

class List < ActiveRecord::Base
  belongs_to :user
  has_many :celebs
end

class Celeb < ActiveRecord::Base
  belongs_to :list
end

I want to load a user's list, and include the celebs that belong to it. I 
tried the following:

@user = current_user

... @list = user.list.joins(:celebs)
... @list = user.list(:include => :celebs)
... @list = user.list.includes(:celebs)

The result was some errors/unexpect output. The expected query is:

SELECT * FROM lists INNER JOIN lists.id ON celebs.list_id WHERE 
lists.user_id = @user_id

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/QtXHPBoCAOwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to