If the intent is to always return a user object, perhaps a different method name such as find_or_initialize_by_login would make the intent more clear. get_by_login makes me think a login object or null/error as a result.
Renaming to something like "find_or_initialize_by_login" would be more accurate and in at least one way is the right answer. Except that it's not the right answer here which helps me see that it's the behavior of the method that is wrong. Thanks for the alternate angle on it.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If the intent is to always return a user object, perhaps a different method name such as find_or_initialize_by_login would make the intent more clear. get_by_login makes me think a login object or null/error as a result.
Renaming to something like "find_or_initialize_by_login" would be more accurate and in at least one way is the right answer. Except that it's not the right answer here which helps me see that it's the behavior of the method that is wrong. Thanks for the alternate angle on it.