Estoy intentando filtrar los registros por fecha, sin embargo no estoy seguro que podria faltarme ya que aunque en la url aparece el parametro obtenido este no filtra nada, no muestra ningun item, a continuación comparto mi codigo:
clients_controller.rb
class ClientsController < ApplicationController
def index
if params[:created_at].present?
@clients = Client.where(created_at: params[:created_at])
else
@clients = Client.all
end
end
end
index.html.erb
<%= form_tag({ controller: :clients, action: :index }, { method: :get } ) do %>
<%= date_field_tag :created_at %>
<%= submit_tag "Filtrar", name: nil %>
<% end %>
<table>
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
<th>Service</th>
<th>Note</th>
<th>Check in</th>
<th>Delivery</th>
<th>Delivered</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @clients.each do |client| %>
<tr>
<td><%= client.name %></td>
<td><%= client.phone %></td>
<td><%= client.service.name %></td>
<td><%= client.note %></td>
<td><%= client.check_in %></td>
<td><%= client.delivery %></td>
<td><%= client.delivered %></td>
<td><%= link_to 'Show', client %></td>
<td><%= link_to 'Edit', edit_client_path(client) %></td>
<td><%= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<%= link_to 'New Client', new_client_path %>