views:

42

answers:

2

What can i do you find a case insensitive search

>> Band.find_by_name("metallica")
=> nil
>> Band.find_by_name("Metallica")
=> #<Band id: 3, name: "Metallica", created_at: "2010-10-03 01:17:24", updated_at: "2010-10-03 01:17:24", user_id: "4">

I need to find the record in both cases...any suggestions?

A: 

Unfortunately, you have to put in some raw sql for this.

Band.find :conditions => ['name ILIKE ?', 'metallica'] #if you are using postgres...
Matt Briggs
+2  A: 
Band.find(:all, :conditions => ['name = lower(?)', band_name.downcase])
Thiago Diniz