Displaying 1 result from an estimated 1 matches for "topics_us".
Did you mean:
topics_id
2006 May 07
1
Find records not in join with has_many_and_belongs_to
...odel object
is using has_many_and_belongs_to :topics and vice versa. I want to find all
the topics that a user has *not* subscribed to. This is what I''ve got:
@user = User.find(params[:id])
@topics = Topic.find(:all,
:conditions => ["id not in (select topic_id from topics_users where
user_id = ?)", @user.id])
I''ve been told that this kind of NOT IN (SUBQUERY) is an inefficient way of
getting the data, and that using a outer join with an "is null" criteria is
the way to go. So now I''ve got this:
@user = User.find(params[:id])...