diff --git a/app/controllers/employers_controller.rb b/app/controllers/employers_controller.rb index 705fb36..5084659 100644 --- a/app/controllers/employers_controller.rb +++ b/app/controllers/employers_controller.rb @@ -8,7 +8,7 @@ class EmployersController < ApplicationController # GET /employers/:id def show - @employer = Employer.includes(:employer_records, :participants).find(params[:id]) + @employer = Employer.includes(:employer_records, :direct_participants).find(params[:id]) @employer_records = @employer.employer_records.includes(:participant) end diff --git a/app/models/employer.rb b/app/models/employer.rb index d2cb5ca..9da1636 100644 --- a/app/models/employer.rb +++ b/app/models/employer.rb @@ -1,14 +1,13 @@ class Employer < ApplicationRecord - has_many :participants - has_many :workers, through: :participants - has_many :employer_records - has_many :participants, through: :employer_records + # Direct association with participants + has_many :direct_participants, class_name: 'Participant' - # Association with Vendor if needed + # Association through EmployerRecord + has_many :employer_records + has_many :indirect_participants, through: :employer_records, source: :participant - def full_name - "#{first_name} #{last_name}" - end - - end - \ No newline at end of file + # Association with Workers through direct_participants + has_many :workers, through: :direct_participants + + # Other methods... +end diff --git a/app/views/employers/show.html.erb b/app/views/employers/show.html.erb index d22ccb2..a206e56 100644 --- a/app/views/employers/show.html.erb +++ b/app/views/employers/show.html.erb @@ -54,15 +54,14 @@ -
Participant Name | @@ -72,29 +71,69 @@|||
---|---|---|---|
<%= "#{participant.first_name} #{participant.last_name}" %> | -<%= employer_record.start_date.strftime('%B %d, %Y') if employer_record.start_date %> | -<%= employer_record.end_date.strftime('%B %d, %Y') if employer_record.end_date %> | -- <%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %> - - <% end %> - <%= link_to edit_employer_record_path(employer_record), class: 'btn btn-sm btn-info' do %> - - <% end %> - | -
<%= "#{participant.first_name} #{participant.last_name}" %> | +<%= employer_record.start_date.strftime('%B %d, %Y') if employer_record.start_date %> | +<%= employer_record.end_date.strftime('%B %d, %Y') if employer_record.end_date %> | ++ <%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %> + + <% end %> + <%= link_to edit_employer_record_path(employer_record), class: 'btn btn-sm btn-info' do %> + + <% end %> + | +
No linked participants.
<% end %>Worker Name | +Start Date | +End Date | +Actions | +
---|---|---|---|
<%= worker.full_name %> | +<%= employment.start_date.strftime('%B %d, %Y') if employment.start_date %> | +<%= employment.end_date.strftime('%B %d, %Y') if employment.end_date %> | ++ <%= link_to worker_path(worker), class: 'btn btn-sm btn-secondary' do %> + + <% end %> + <%= link_to edit_employment_path(employment), class: 'btn btn-sm btn-info' do %> + + <% end %> + | +
No linked workers.
+ <% end %> + +