Has many to one query

– MODELS –
Model User
has_many :profs
has_many :skills, :through => :prof

Model Prof
belongs_to :user # user_id
belongs_to :skill # skill_id

Model Skill
has_many :profs

– CONTROLLER –

searched_skills = [2,18,6] # comes from params[:search_skills]
I need to find @users who having ALL of searched skills.
current code:
@users = User.paginate :conditions => [“profs.skill_id IN (?)”,
searched_skills], :include => :profs, :page => page
does not help (since it use OR). It returns all users who having at
least one of searched_skills.
I need this thing in one query that return @users paginated array
(will_paginate)

im late night 4 hours work, plz dont judge me :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs