diff --git a/app/controllers/vendors_controller.rb b/app/controllers/vendors_controller.rb index eaf9d82..8fcc026 100644 --- a/app/controllers/vendors_controller.rb +++ b/app/controllers/vendors_controller.rb @@ -5,6 +5,7 @@ class VendorsController < ApplicationController def show @vendor = Vendor.find(params[:id]) + @sorted_participants = @vendor.service_contracts.includes(:participant).map(&:participant).sort_by(&:last_name) end def new diff --git a/app/views/vendors/show.html.erb b/app/views/vendors/show.html.erb index ecc0205..31930b5 100644 --- a/app/views/vendors/show.html.erb +++ b/app/views/vendors/show.html.erb @@ -55,7 +55,7 @@

Linked Participants

- <% if @vendor.participants.any? %> + <% if @sorted_participants.any? %> @@ -66,21 +66,22 @@ - <% @vendor.service_contracts.each do |contract| %> - - <% participant = contract.participant %> - - - - - + <% @sorted_participants.each do |participant| %> + <% participant.service_contracts.each do |contract| %> + + + + + + + <% end %> <% end %>
<%= participant ? "#{participant.first_name} #{participant.last_name}" : 'No Participant Assigned' %><%= contract.start_date.strftime('%B %d, %Y') if contract.start_date.present? %><%= contract.end_date.strftime('%B %d, %Y') if contract.end_date.present? %> - <%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %> - - <% end %> - <%= link_to edit_service_contract_path(contract), class: 'btn btn-sm btn-info' do %> - - <% end %> -
<%= "#{participant.first_name} #{participant.last_name}" %><%= contract.start_date.strftime('%B %d, %Y') if contract.start_date %><%= contract.end_date.strftime('%B %d, %Y') if contract.end_date %> + <%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %> + + <% end %> + <%= link_to edit_service_contract_path(contract), class: 'btn btn-sm btn-info' do %> + + <% end %> +
@@ -89,3 +90,4 @@ <% end %>
+