I am trying to limit the results of the filterrific search to only instances that have a given client_id.
My set up is as follows:
# customers_controller.rb
@filterrific = initialize_filterrific(
Customer,
params[:filterrific],
select_options: {
sorted_by: Customer.options_for_sorted_by,
with_agent_id: Agent.options_for_select
},
) or return
Is there a way to limit the returned active record results, like Customer.where('client_id', 2) ?
You can do that like this:
@filterrific = initialize_filterrific(
Customer,
params[:filterrific],
select_options: {
sorted_by: Customer.options_for_sorted_by,
with_agent_id: Agent.options_for_select
},
) or return
@customers = @filterrific.find.where(client_id: 2).paginate(:page => params[:page], :per_page => 10) # add paginate if you require pagination