Skip to content

Instantly share code, notes, and snippets.

@danmcclain
Created October 17, 2011 13:06
Show Gist options
  • Save danmcclain/1292563 to your computer and use it in GitHub Desktop.
Save danmcclain/1292563 to your computer and use it in GitHub Desktop.
#...
has_many :notes_students
has_many :students, through: :notes_students
#...
assigned_note_ids = NotesStudent.select("DISTINCT(note_id)").map{|ns| ns.note_id}
@notes = current_school.notes.where("id NOT IN (?)", assigned_note_ids).page(params[:page])
belongs_to :note
belongs_to :student
#...
has_many :notes_students
has_many :notes, through: :notes_students
#...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment