Ruby on rails 3 Rails 3和元搜索

Ruby on rails 3 Rails 3和元搜索,ruby-on-rails-3,meta-search,Ruby On Rails 3,Meta Search,我正在尝试在我的应用程序中实现meta_search gem,以过滤账单表中的各个字段: class PeriodBillingsController < ApplicationController def index @sla = Sla.find(params[:sla_id]) @search = PeriodBilling.latest_billing.search(params[:search]) @period_billings

我正在尝试在我的应用程序中实现meta_search gem,以过滤账单表中的各个字段:

  class PeriodBillingsController < ApplicationController
    def index
      @sla = Sla.find(params[:sla_id])
      @search = PeriodBilling.latest_billing.search(params[:search])
      @period_billings = @search.order("we_date desc").where("sla_id = ?", @sla.id)
    end
  end
类周期BillingController
以及以下观点:

  <%= form_for @search do |f| %>
    <%= f.label :pe_number_eq, "Period #" %>
    <%= select("period_billing", "pe_number", (1..12), {:include_blank => true}) %>
    <%= f.label :appcode_eq, "Appcode" %>
    <%= collection_select( "period_billing", "appcode_id", Appcode.where("sla_id = ?", @sla.id), :id, :appcode, :include_blank => true ) %>
    <%= f.label :dpc_employee_eq, "Named Resource" %>
    <%= collection_select( "period_billing", "dpc_employee_id", DpcEmployee.all, :id, :fullname, :include_blank => true ) %>
  <%= f.submit "Filter Records" %>
  <% end %>

真})%%>
正确)%%>
正确)%%>
当我单击选择其中一个过滤器时,我得到一个错误:

找不到没有ID的Sla

我假设这是因为我的@sla.id参数没有被带到@search,但我不知道我做错了什么。请帮助一个贫穷、过度劳累的女孩,她正与此抗争


提前感谢您的建议。

我认为它相当缺失:调用索引时的sla_id参数。

这一行

@sla=sla.find(参数[:sla\u id])

应该看起来像

@search=Sla.serch(参数[:search])

因为我假设您正在使用索引操作来显示sla中的所有记录

但在show中,您正在与params:id一起使用

@sla=sla.find(参数[:id])

也许这是一个迟来的反应,但可能有人会有同样的问题