Could this be done with a `find_or_initialize_by`? If that works, it should be able to clean up the if/else inside the transaction.