File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ruby and the fly likes Case insensitive search in Rails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Ruby
Bookmark "Case insensitive search in Rails" Watch "Case insensitive search in Rails" New topic

Case insensitive search in Rails

Rahul Chandran

Joined: Oct 14, 2010
Posts: 20
Is there any method or action in Rails 3 for case insensitive search ?

this is the code i use for searching and the database is sqlite3.
If i search for clint using this code it doesn't return any value but if searched for Clint it shows up with the results.

Thank You.
Katrina Owen

Joined: Nov 03, 2006
Posts: 1367
If you want all your searches on that column to be case insensitive (and because you are using sqlite3) you can specify at the database level.

If you just want that particular query to be case insensitive, you're going to need to jump through a couple more hoops, I think (I rarely use sqlite3, so there may be other options that I'm not aware of).

That will still probably fail for names with accents or funky Scandinavian characters, though.

On an unrelated note, I suggest that you add a method to your ClientWorkouts model called or some such thing that you call from your controller :)
I agree. Here's the link:
subject: Case insensitive search in Rails
jQuery in Action, 3rd edition