In my Rails app I want to find a user by their email, or if the user does not exist, create one with that email as well as a few other attributes. Is there a less clunky way than the code below to do this, perhaps using find_or_create_by?
def set_user
if self.user = User.find_by(email: recipient)
else
self.user = User.create(email: recipient,
password: Devise.friendly_token.first(6),
confirmed_at: DateTime.now)
end
end