Ruby on rails Rails 4-通过集合过滤索引\u在索引操作上选择表单中的值

Ruby on rails Rails 4-通过集合过滤索引\u在索引操作上选择表单中的值,ruby-on-rails,forms,scope,ruby-on-rails-4,filtering,Ruby On Rails,Forms,Scope,Ruby On Rails 4,Filtering,在记录的“索引操作”页面上,我希望有一个包含客户、组和用户的集合选择的表单(该表单,我已包含相关集合选择)…但我不知道如何使表单提交按钮返回过滤的索引页面 我已经设置了scopes,只是不知道如何从表单中调用它们 带作用域的记录模型: _索引\过滤器\表单局部视图: Records Controller:最初,我在视图中将此作为我的: Record: belongs_to :user has_one :course has_one :client, through: :user

在记录的“索引操作”页面上,我希望有一个包含客户、组和用户的集合选择的表单(该表单,我已包含相关集合选择)…但我不知道如何使表单提交按钮返回过滤的索引页面

我已经设置了scopes,只是不知道如何从表单中调用它们

带作用域的记录模型:

_索引\过滤器\表单局部视图:


Records Controller:

最初,我在视图中将此作为我的:

Record:
  belongs_to :user
  has_one :course
  has_one :client, through: :user
  has_one :group, through: :user
其中,by_客户端、by_组和by_用户是记录模型中的命名作用域

<td><%= collection_select(:client_id, 0, Client.find(:all, :order => "name"), :id, :name, {}, {:class=>'form-control'}) %></td>
<td><%= collection_select(:group_id, 0, Group.find(:all, :order => "name"), :id, :name, {}, {:class=>'form-control'}) %></td>
<td><%= collection_select(:user_id, 0, User.find(:all, :order => "first_name, last_name"), :id, :full_name, {}, {:class=>'form-control'}) %></td>
<!-- collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {}) -->
<td><%= collection_select(:client, :id, Client.find(:all, :order => "name"), :id, :name, {}, {:class=>'form-control'}) %></td>
<td><%= collection_select(:group, :id, Group.find(:all, :order => "name"), :id, :name, {}, {:class=>'form-control'}) %></td>
<td><%= collection_select(:user, :id, User.find(:all, :order => "first_name, last_name"), :id, :full_name, {:multiple => true, :size => 5}, {:class=>'form-control'}) %></td>
def index
    @records = Record.all
    if params[:commit] == "Filter"
      @records.by_client(params[:client_id]).by_group(params[:group_id]).by_user(params[:user_id])
    end
end