Project

filta

0.0
A long-lived project that still receives updates
Simple filtering for ActiveRecord, inspired by Justin Weiss 'Gist - https://gist.github.com/justinweiss/9065666
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 6, < 8
 Project Readme

Filta

Super simple filtering for ActiveRecord, inspired by Justin Weiss' Gist.

Gem Version CI

Requirements

  • Ruby >= 3.0
  • Rails >= 6, < 8

Installation

Add this line to your application's Gemfile:

gem "filta"

And then execute:

$ bundle

Or install it yourself as:

$ gem install filta

Usage

Use like you would any other kind of ActiveRecord scope.

@filtered = Klass.filta(title: "Foo", something: "Bar")
@filtered = Klass.filta({ title: "Foo", something: "Bar" }) # Can also use with hash

The filta method returns an ActiveRecord relation so you can chain the calls with other methods.

Klass.filta(title: "Foo").order("created_at DESC")

If using in a controller make sure you use the params.permit method to sanitize what you pass into the filta method.

Contributing

  • Check out the latest master and/or develop branches to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch off of develop (using Git Flow approach)
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally
  • When you are done generate a pull request
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

License

The gem is available as open source under the terms of the MIT License.