How to do case-insensitive order in Rails with postgresql

brad picture brad · Jun 6, 2010 · Viewed 22.1k times · Source

I am in the process of switching my development environment from sqlite3 to postgresql 8.4 and have one last hurdle.

In my original I had the following line in a helper method;

result = Users.find(:all, :order => "name collate NOCASE")

which provided a very nice case-insensitive search. I can't replicate this for postgresql. Should be easy - any ideas?

Thanks.

Answer

LanceH picture LanceH · Jun 6, 2010
result = Users.find(:all, :order => "LOWER(name)")

To take a little bit from both Brad and Frank.