https://github.com/coreyjs/rogue_filter
Easy ActiveRecord filtering with search parameters
https://github.com/coreyjs/rogue_filter
Last synced: 11 months ago
JSON representation
Easy ActiveRecord filtering with search parameters
- Host: GitHub
- URL: https://github.com/coreyjs/rogue_filter
- Owner: coreyjs
- License: mit
- Created: 2018-02-04T21:29:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T15:32:44.000Z (over 8 years ago)
- Last Synced: 2025-04-09T02:46:55.611Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/corey-rb/rogue_filter)
# 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
```ruby
class Car < ApplicationRecord
acts_as_filterable
scope :rogue_name, -> (name) { where name: name }
end
```
All custom scopes that you want to get called must be prefixed with `rogue_`.
controller.rb
```ruby
Car.filterable({name: 'Corey'})
```
* RogueFilter will define the class method `filterable` on all models that call `acts_as_filterable`
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'rogue_filter'
```
And then execute:
```bash
$ bundle
```
Or install it yourself as:
```bash
$ gem install rogue_filter
```
## Contributing
Contribution directions go here.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
## Mention
This was a learning project, idea was taken from https://www.justinweiss.com/articles/search-and-filter-rails-models-without-bloating-your-controller/ .