我想实现我的应用程序在一个计费表各个领域筛选meta_search宝石:的Rails 3和元搜索
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
和视图:
<%= 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 %>
当我点击选择一个过滤器,我得到一个错误:
Couldn't find an Sla without an ID.
我假设这是因为我的@ sla.id参数没有被带到@搜索,但我不知道我做错了什么。请帮助一位正在为此苦苦挣扎的穷人,过度劳累的女孩。 ;)
在此先感谢您的任何建议。