I have this authenticate! method where I am trying to retrieve their account based on the subdomain, then find the user. if user is found & their password is matched, we return success, else fail in all other cases. here is the code:def authenticate!    account = Account.find_by(subdomain: subdomain)    if account      u = account.users.find_by email: params[user][email]      if u.nil?        fail!      else        u.authenticate(params[user][password]) ? success!(u) : fail!      end    else      fail!    endendNow, I could simply this further by moving subdomain into a helper method, def subdomain  ActionDispatch::Http::URL.extract_subdomains(request.host, 1)enddef authenticate!      account = Account.find_by(subdomain: subdomain)      if account        u = account.users.find_by email: params[user][email]        if u.nil?          fail!        else          u.authenticate(params[user][password]) ? success!(u) : fail!        end      else        fail!      endendBut how to I simply these nested conditionals?
Rails authentication checks
ruby;ruby on rails;authentication
Another view on @tokland solution:def authenticate!  return fail! unless account = Account.find_by(subdomain: subdomain)  return fail! unless user = account.users.find_by(email: params[user][email])  return fail! unless user.authenticate(params[user][password])  success! userendThis intention is to be as close to original task explained in common English as possible. And return keyword allows me to do that.