https://github.com/pikachuexe/where_lower
Provide an easy way to use case insensitive `where` in ActiveRecord.
https://github.com/pikachuexe/where_lower
activerecord gem rails ruby ruby-on-rails
Last synced: 10 months ago
JSON representation
Provide an easy way to use case insensitive `where` in ActiveRecord.
- Host: GitHub
- URL: https://github.com/pikachuexe/where_lower
- Owner: PikachuEXE
- License: mit
- Created: 2013-03-22T09:48:26.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2024-12-26T00:23:21.000Z (over 1 year ago)
- Last Synced: 2025-01-02T09:21:58.452Z (over 1 year ago)
- Topics: activerecord, gem, rails, ruby, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 107 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# where_lower
Provide an easy way to use case insensitive `where` in ActiveRecord.
## Status
[](https://github.com/PikachuEXE/where_lower/actions/workflows/tests.yaml)
[](http://badge.fury.io/rb/where_lower)
[](http://badge.fury.io/rb/where_lower)
[](https://coveralls.io/r/PikachuEXE/where_lower)
[](https://codeclimate.com/github/PikachuEXE/where_lower)
[](https://inch-ci.org/github/PikachuEXE/where_lower)
> The above badges are generated by https://shields.io/
## Installation
```ruby
gem 'where_lower'
```
## Usage
Supports `String`, `Array`, `Range`
Values in `Array` and `Range` will be converted to `String` and then `downcase`
Other types will not be touched
```ruby
SomeActiveRecordClass.where_lower(attribute1: 'AbC', attribute2: ['stRing', 123, :symBol], attribute3: ('AA'..'AZ'))
```
### Since `0.3.0`
You can pass a nested hash (1 level deep only) for association condition
```ruby
record.association_records.where_lower(association_table: {association_column: value})
```
You can also add table name in key if you are using it with association
I don't plan to support any "smart" table guessing though
```ruby
record.association_records.where_lower('association_table.association_column' => value)
```
## Contributors
- [Matthew Rudy Jacobs](https://github.com/matthewrudy) (Who wrote the first version of `where_lower` method)