ユーザーが見つからない場合は User または nil を返す関数があります。次のようになります。
# Given an access token in the HTTP headers, it returns the User who owns the token
#
# @return [User] the user who owns the access token
def set_api_user
token = /(.*)=\"(.*)\"/.match(request.headers["Authorization"])[2]
@api_user = ApiKey.find_by(access_token: token).user
end
私の質問は、それが見つからない場合に User または nil を返すことをどのように文書化するのですか?