RogueFilter
Rogue Filter makes it easy to add scopes to ActiveRecord models. This is helpful when chaining together multiple scopes on models that have many search parameters.
Usage
model.rb
class Car < ApplicationRecord
acts_as_filterable
scope :rogue_name, -> (name) { where name: name }
endAll custom scopes that you want to get called must be prefixed with rogue_.
controller.rb
Car.filterable({name: 'Corey'})- RogueFilter will define the class method
filterableon all models that callacts_as_filterable
Installation
Add this line to your application's Gemfile:
gem 'rogue_filter'And then execute:
$ bundleOr install it yourself as:
$ gem install rogue_filterContributing
Contribution directions go here.
License
The gem is available as open source under the terms of the MIT License.
Mention
This was a learning project, idea was taken from https://www.justinweiss.com/articles/search-and-filter-rails-models-without-bloating-your-controller/ .