I have a search form on an employee locator page. I can enter a letter to filter the names, but when I click on next page I'm getting: ActionController::UnknownFormat at /employee_locators/search. It's saying the error is on the respond_to block. Here is the search method in employee_locators_controller
def search
@employees = Employee.active_name_search(params[:name])
.employee_locator_list
.order(:lname, :fname)
.paginate(page: params['page'], per_page: 15)
respond_to do |format|
format.js
end
end
Here is the route
resources :employee_locators, only: [:index, :show] do
get 'search', on: :collection
This is the partial in the view(I didn't write the POST comment at the bottom)
<table class="search-results-table table">
<thead>
<tr>
<th tabindex="0" id="first_name_heading">First Name</th>
<th tabindex="0" id="last_name_heading">Last Name</th>
<th tabindex="0" id="division_heading">Division</th>
<th tabindex="0" id="room_heading">Room</th>
<th tabindex="0" id="phone_heading">Phone</th>
</tr>
</thead>
<tbody>
<%- employees.each do |employee| -%>
<tr tabindex="0" data-href="<%= employee_locator_path(employee) %>" aria-label="Select to view <%= employee.fname %> <%= employee.lname %>">
<td aria-labelledby='first_name_heading'><%= employee.fname %></td>
<td aria-labelledby='last_name_heading'><%= employee.lname %></td>
<td aria-labelledby='division_heading'><%= employee.active_org.division %></td>
<td aria-labelledby='room_heading'><%= employee.blding_room %></td>
<td aria-labelledby='phone_heading'><%= employee.work_phone %></td>
</tr>
<%- end -%>
</tbody>
</table>
<% # The following is a bit of a hack around will_paginate not inheriting POST data %>
<div role="navigation" aria-label="Page Navigation">
<%= will_paginate employees, params: { search: params[:search], search_type: params[:search_type], fte_type: params[:fte_type]} %>
</div>
I've tried adding in a format.html to the respond_to block and that changes the error to: EmployeeLocatorsController#search is missing a template for this request format and variant.
I didn't write the code above, but I'm tasked with fixing this bug.