Case sensitive find_by

Hi all,

Do any one knows how to make find_by method case sensitive?

Thanks in advance,
Mostafa Badawi

Hi

Do any one knows how to make /find_by/ method case sensitive?

Case sensitivity doesn’t depend on rails, but on your DBMS settings.

Assuming you are using mysql, the default encoding/collation are latin1
and latin1_swedish_ci where “_ci” stands for “case insensitive”.

If you want to run all your queries in a case sensitive way, you can
just change the encoding of your database or of that particular table or
column.

If you want to use it in a single query, you can use the COLLATE
operator as a part of your condition and specify a case sensitive
collation.

If you are not using MySQL, still the theory is the same, but the
details will change :wink:

good luck,


javier ramírez

…i do ruby on rails development in madrid, spain, at
http://www.aspgems.com
…you can find out more about me on http://formatinternet.wordpress.com
and http://workingwithrails.com/person/5987-javier-ramirez