Possible Enhancement method - City.where(name: approximates("york"))

There are several times where we are looking for approximate strings, like parte of an email o a name.
We are not sure if the mail is correctly written or if a name is using correct capitalization, so we usually go with

City.where(“name ilike ?”, “%york%”)

``

Would it be better to have something like

City.where(name: approximates(“york”))

``

Is this kind of change aesthetic or not? For me it would be quite comfortable, but its not that big of a change.

This could be used while checking for information in a Rails Console or event a search method.

It would also be great to have an even short approximation method, like so

City.where.approx(name: “francisco”)

``

or

City.where.approx(population: 1000000)

``

The interpretation of the approximates with numbers would be quite difficult to agree upon, but I’m sure it could be of great help, maybe something like this could work

City.where.approx(population: 1000000, radius: 0.1)

``

So that goes around ± 10% of the given value, but that would interefere with an attribute called radius…well…

Text search is a complex topic and is covered well by many existing gems. I don’t believe this should be in Rails core personally.