I have three tables: User, User_Interest, and Interest
How could I get the interest names that one of the users doesn’t have?
(I have already set up the model for all of them.)
Thanks for your kindly help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could make this a class method on User, or an instance method on a particular user. For the class method, try this:
and call it with
User.missing_interests(some_user). For instance, tryand call with
missing = some_user.missing_interests.That should return an array with the names of all interests not included in the
interestsassociation for user.