In a Rails 3.2 app I have a Tag
model and want to find all records where the value in the name:string
field is all lowercase.
Thus the activerecord query (on Postgres) would return Tag(id: 1, name: 'test')
but not Tag(id:2, name: 'Test')
.
I'm sure there's a straightforward way to do this but I haven't been able to produce a working query!
This should work:
Tag.where('name = lower(name)')
If name
equals lower(name)
it means that name
is lowercase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With