See the details below to make sense.
I am trying to write a line of code that will be searching the database and show the users that have a specific skill.
My clue is that I should be using something like @user.where('skill = ?', skillvariable)
or a specific query. Any point/guidance to the right direction is greatly appreciated.
Details:
I have a users model, a skills model and a user_skills model.
In user.rb I have the relation has_many :skills, through: :user_skills
.
In the skill.rb I have the relations has_many :user_skills
and has_many :users, through: :user_skills
,
and then in user_skills.rb I have the belongs_to :user
and belongs_to :skill
.
The user_skills schema is:
t.integer "user_id"
t.integer "skill_id"
And the skills schema is:
t.string "name"
t.string "slug"