Verified Commit ac8a7c62 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

default filter q params through controller method

parent cfb130e5
......@@ -8,7 +8,7 @@ class ClientsController < ApplicationController
def index
authorize Client
@q = policy_scope(Client).ransack(params[:q])
@q = policy_scope(Client).ransack(default_filter)
@q.sorts = ['created_at desc'] if @q.sorts.empty?
@clients = @q.result
respond_to do |format|
......@@ -80,6 +80,15 @@ class ClientsController < ApplicationController
private
def default_filter
return { acceptance_not_eq: 2 } if params[:q].blank?
filters = params.to_unsafe_hash[:q]
if filters[:acceptance_eq].present? || filters[:contact_full_name_cont].present?
filters.except(:acceptance_not_eq)
else
filters.merge(acceptance_not_eq: 2)
end
end
end
def set_client
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment