-
-
Save Sailias/903773 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@candidates = @assignment.assignment_lists.includes({:candidates=>{:histories=>:institutions}} | |
.where('histories.finish_date IS NULL') | |
.order("institutions.name, candidates.last_name) | |
.group('candidates.id) | |
for can in @candidates | |
puts can.last_name | |
puts histories.job_title | |
puts institutions.name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment