Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Case insensitive search in Rails

Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Posts: 1367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :)
Bras cause cancer. And tiny ads:
Two software engineers solve most of the world's problems in one K&R sized book
    Bookmark Topic Watch Topic
  • New Topic