Slide 125
Slide 125 text
class Finance::TransactionsSearch
include SearchObject.module(:kaminary)
scope { Transaction.all }
option :user_id
option :min_amount, with: :filter_by_min_amount
option :max_amount, with: :filter_by_max_amount
option :start_date, with: :filter_by_start_date
option :end_date, with: :filter_by_end_date
private
def filter_by_min_amount(scope, value)
scope.where("amount > ?", value)
end
def filter_by_max_amount(scope, value)
scope.where("amount < ?", value)
end
def filter_by_start_date(scope, value)
scope.where("created_at > ?", value)
end