ex filter one column - maxivak/simple_search_filter GitHub Wiki
Set filter for one column and clear filters for other columns
If you have filters set for a page and want to filter only by one column, then use filter_cmd=set
for a link.
example:
controller:
search_filter :index, {save_session: true, search_method: :post_and_redirect, url: :products_url, search_url: :search_products_url, search_action: :search} do
default_order "price", 'desc'
field :title, :string, :text, {label: 'Title', default_value: '', condition: :like_full, input_html: {style: "width: 240px"} }
field :price_from, :string, :text, {label: 'Price', default_value: '', condition: :custom, condition_where: 'price >= ?', input_html: {style: "width: 140px"} }
field :price_to, :string, :text, {label: 'to', default_value: '', condition: :custom, condition_where: 'price <= ?', input_html: {style: "width: 140px"} }
field :category_id, :int, :select, {label: 'Category', default_value: 0, ignore_value: 0, collection: Category.all, label_method: :title, value_method: :id, include_blank: true }
end
view:
=link_to 'Products in category 1', products_path(filter_cmd: 'set', category_id: 1)
After you click the link it will show products in that category - no matter what filters were set before.