Another newbie question. My dummy app has the following models:class User < ActiveRecord::Basehas_one :list
endclass List < ActiveRecord::Basebelongs_to :userhas_many :celebsendclass Celeb < ActiveRecord::Basebelongs_to :listendI 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)
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You don't normally need to use joins or includes for such things. you
can just say
@list = @user.list
then
celebs = @list.celebs
or just
celebs = @user.list.celebs.
You may have to test for the case where @user.list is nil if it is
possible to have a user that has no list
Colin