sql - Finding all users with specific attribute in a through relation -
See below for details.
I am trying to write a line of code, search the database and show users who have specific skills.
My clue is that I should use something like Description : I have a user model, a skill model and a user_skill model. I have the relation I have a relationship with skill.rb and Then, in user_skills.rb, I have You can do just that: All users with at least one skill named 'Archery' will be there (skill: {name: 'arrowy'}) Recover. Same question: @ user.where ('skill =?', skillvariable). > Or a specific query
in user.rb_m: skill, through: user_skills .
Has_many: user_skills and
has_many: users, through :: user_skills ,
related_to: user and
related_to: skills .
t.string "name" t.string "slug"
User.includes (skills:). This will be lateral:
Comments
Post a Comment