I've a controller for WeekDay
. Then I tried to add RanSack in my project. It works good except when I tried to enable remote true
, it shows only search form. AJAX call is being made, but nothing shows up.
Controller code
def index
@q = WeekDay.ransack(params[:q])
@week_days = @q.result().page(params[:page]).per(10)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @week_days }
end
end
index.html.erb
<div id="week_days"><%= render 'week_days' %></div>
_week_days.html.erb
<%= search_form_for @q,remote: true do |f| %>
<%= f.label :datum_gteq %>
<%= f.date_field :datum_gteq%>
<%= f.label :datum_lteq %>
<%= f.date_field :datum_lteq %>
<%= f.submit %>
<% end %>
<table>
<thead>
<tr>
<th><%=sort_link @q, :datum %></th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @week_days.each do |week_day| %>
<tr>
<td><%= l week_day.datum %></td>
<td><%= link_to 'Show', week_day %></td>
<td><%= link_to 'Edit', edit_week_day_path(week_day) %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @week_days %>
<br>
<%= link_to 'New Week Day', new_week_day_path %>