How do I get either true or false on a database find in Rails?
Say if I have a database with username field and a password field. I want to find a certain username in my database and return true if I found it or false if I didn’t. I’m a noob and I tried googling it but could not find anything.
ex.
q = User.new
q.username = "Joe"
q.password = "password"
User.find_by_username("Joe") -> true
User.find_by_username("Admin") -> false
Thanks for the help.
1 Answer