-
Notifications
You must be signed in to change notification settings - Fork 0
filter data
Max Ivak edited this page Jul 1, 2015
·
2 revisions
# 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 directly:
def index
@filter.set 'user_id', current_user.id
end