Reputation: 7166
Model.exists?("lower(email) = ?", params[:email].downcase)
Returns error: ArgumentError (wrong number of arguments (2 for 0..1)):
Is it possible to do a exists?
with a case insensitive match?
Upvotes: 8
Views: 2252
Reputation: 1490
All you need to do is this:
Model.exists?(["lower(email) = ?", params[:email].downcase])
It's looking for a single argument but you're providing two. Using the array form and the find-style conditional should get what you need.
Upvotes: 15
Reputation: 8821
You also can do like this:
Model.where("lower(email) = ?",params[:email].downcase).exists?
Upvotes: 9