Before Rais 6, if you want to delete an user with name
Alice, you could do this way:
user = User.find_by name: "Alice" user&.destroy
This way is quite long, so Rails 6.0 provides method
delete_by) as an alias for old way to delete a record with condition.
No optimize for code here, just an short way to call. You could view more detail code is in this pull request.