Today I learned a way to implement a login form that accepts email or username as the login. I’ve been on the other side of a form like this many times, but had never written one myself.
Here’s one solution, with ActiveRecord:
User.where('username = ? or email = ?', "jwworth", "email@example.com")
slug are represented by the same parameter, and either can be
login = params.fetch('username_or_email') User.where('username = ? or email = ?', login, login)