I found that if a user registers with an email and use a capital letter in their email when I do the following I get nil.
Example:
username = [email protected]
params[:user][:email] = [email protected]
user = User.find_by_email(params[:user][:email])
user.nil?
=> true
How can I search for an email without the problems of case sensitivity or how an I write a find_by_email that is case insensitive?
If a user(say X) has an email '[email protected]', then
User.find(:all, :conditions => ["lower(email) =?", "[email protected]"])
should return the user X. I didnt replicate the situation but that is what I guess you essentially need to do.
Or, more better, use where instead of find as pointed out by @MrTheWalrus
User.where('lower(email) = ?', "[email protected]").first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With