ruby on rails - How do I use ActiveRecord to find unrelated records? -
I have a lot of connections through a connecting model. Basically, I allow people to express interest in activities I am
class activity & lt; ActiveRecord :: Base has has_many: personal_interests has_many: people ,: through = & gt; : Individual / interested end-of-life people & lt; ActiveRecord :: Base has has_many: personal_interests has_many: activities, through: = & gt; : Individual / interest-in-class personal interest & lt; ActiveRecord :: Base is_to: person belongs_to: end of activity
Now I want to find out: Is there any specific user not interested expressed? This includes activities that others interested in and others interested in is not interested.
A successful (but incompetent) method was two separate questions:
(activity .all - this_person.interests) .first
How do I neatly silence this query in ActiveRecord? Is there any (reliable, well-kept) plugin that summarizes questions?
I find the easiest way to do an : conditions through a SQL
where
use the section section.
For example:
activity. All (: conditions => ['does not exist (select 1 from personal interest, where person_itis = and activity_id = Activities.id) ', this_person.id])
Completely undesired, and probably does not work properly, but you get this idea.
Comments
Post a Comment