Hi, I have a fairly typical has_many, through setup with a bit of a twist.
class Course < ActiveRecord::Base has_many :placements has_many :students, :through => :placements end class Student < ActiveRecord::Base has_many :placements has_many :courses, :through => :placements end class Placements < ActiveRecord::Base belongs_to :course belongs_to :student end
So with this I could grab all the students for a course by:
@students = @course.students
Everything is fine so far, but here is the twist. I have to narrow things down by some data on the placements table. Let’s say I have a column called “placed_by” on “Placements”
How would I retrieve all of the students for a course if I only wanted to see those who were placed by “Bob” for example?