我将Filterrific gem用于活动记录过滤器。我为每个记录和每个记录都有一个表格提供了一个编辑选项。在尝试提交表单之后,我已经过滤了表中的记录,但是没有发生。表格渲染是通过Filterrific进行的。
过滤形式
<%= form_for_filterrific @filterrific do |f| %>
<%= f.text_field :search_by_site_name, class: 'form-control', id: "filter_site_name" %>
<%= link_to( 'Reset filters', reset_filterrific_url, class: 'btn btn-cust-danger full-width') %>
<%= render_filterrific_spinner %>
<% end %>
<div id="filterrific_results">
<%= render(
partial: 'v2/admins/data_repo_files/list',
locals: { data_repo_files: @data_repo_files }
) %>
</div>
js erb文件
<% js = escape_javascript( render(partial: 'v2/admins/data_repo_files/list', locals: { data_repo_files: @data_repo_files })) %>
$("#filterrific_results").html("<%= js %>");
编辑表单
<div class="modal fade" id="edit_data_repo_file_<%= data_repo_file.id %>" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Edit Data Repo File</h4>
</div>
<%= form_for :data_repo_file, url: v2_admins_data_repo_file_path(data_repo_file.id), method: :put do|f| %>
<div class="modal-body">
<%= f.text_field :site_name, class: "form-control" %>
<%= f.text_field :price, class: "form-control" %>
</div>
<div class="modal-footer">
<%= f.submit "Update", class: "btn btn-cust-success" %>
</div>
<% end %>
</div>
</div>
</div>