how can I write a case-insensitive find_by_email for Rails 3

孤人 提交于 2019-12-05 13:39:58

If a user(say X) has an email 'Dillan@example.com', then

User.find(:all, :conditions => ["lower(email) =?", "dillan@example.com"]) 

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) = ?', "dillan@example.com").first
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!