Skip to content

Instantly share code, notes, and snippets.

@8vius
Created October 6, 2015 20:47
Show Gist options
  • Save 8vius/a1f6f87ef95d767e9e67 to your computer and use it in GitHub Desktop.
Save 8vius/a1f6f87ef95d767e9e67 to your computer and use it in GitHub Desktop.
module Filterable
extend ActiveSupport::Concern
module ClassMethods
def filter(filtering_params)
results = where(nil)
filtering_params.each do |key, value|
results = results.public_send(key, value) if value.present?
end
results
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment