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.
User.exists?(:username => "Joe")
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