I have a many-to-many relationship between Jobs & Stacks via JobStacks. I'm trying to write an ActiveRecord query to return Jobs containing ALL of the Stacks passed to it.
class Job < ApplicationRecord  
  has_many :job_stacks
  has_many :stacks, through: :job_stacks
end
class JobStack < ApplicationRecord
  belongs_to :job
  belongs_to :stack
end
class Stack < ApplicationRecord
  has_many :job_stacks, dependent: :destroy
  has_many :jobs, through: :job_stacks
end
This creates an SQL IN query returning Jobs containing ANY of the stacks.
Job.joins(:stacks).where(stacks: {name: ['JavaScript', 'Python']})
Is there a similar way to write this returning Jobs containing all of the Stacks as a .where call from Jobs?
 
     
    