Skip to content

Instantly share code, notes, and snippets.

@onlymejosh
Created April 5, 2011 14:50
Show Gist options
  • Save onlymejosh/903745 to your computer and use it in GitHub Desktop.
Save onlymejosh/903745 to your computer and use it in GitHub Desktop.
def show
authorize! :assignment, :show
@assignment = Assignment.find(params[:id])
@related_logs = @assignment.assignment_logs.page(params[:page]).per(4).order('assignment_logs.date DESC').includes(:user)
# do a find to find and order candidates by there current employment
@candidates = AssignmentList.where('assignment_lists.assignment_id = ?', @assignment.id)
.joins('LEFT JOIN candidates ON assignment_lists.candidate_id = candidates.id
LEFT JOIN histories ON histories.candidate_id = candidates.id AND histories.finish_date IS null
LEFT JOIN institutions ON histories.institution_id = institutions.id')
.order('institutions.name ASC, candidates.last_name ASC')
.select('candidates.*, histories.job_title, institutions.name')
.group('candidates.id')
respond_with(@assignment)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment