I want to check if a record already exist in my database. In my function i have this code:
mailcode = params[:q] check = User.where("custom_mailcode = 'mailcode'").first Now i'm in trouble with the if statement. I think to do something like that:
if check == nil doing something else doing something end But it doesn't work because check is never nil. How can i fix that?
.firstwould returnnilso it should just work.where(...).firstis typically done viafind_by(...).