filter data - maxivak/simple_search_filter GitHub Wiki

Access filter data

Use filter data in action:

# app/controllers/products_controller.rb

class ProductsController < ApplicationController

...
def index
	@items = Product.by_filter (@filter)

	# or
	@items = Product.where(@filter.where).order(@filter.order_string).page(@filter.page)

	# or use filter values in where
	category_id = @filter.v(:category_id)

	@items = Product.where(:category_id=> category_id).page(@filter.page)

end


end

Set value for filter

set value directly:

def index
	@filter.set 'user_id', current_user.id
end