Module: Trek::Filters
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/trek/filters.rb
Defined Under Namespace
Classes: NotAppliedError
Instance Method Summary collapse
Instance Method Details
#apply_filters(scope, filters) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/concerns/trek/filters.rb', line 25 def apply_filters(scope, filters) return scope if filters.blank? filters.each do |filter, value| next if value.blank? value = nil if value == "nil" scope = scope.where(filter => value) end scope end |
#apply_filters! ⇒ Object
38 39 40 41 |
# File 'app/controllers/concerns/trek/filters.rb', line 38 def apply_filters! @filters_applied = true @objects = apply_filters(@objects, params[:filters]) end |