title: If ActiveRecord::Base.transaction succeeded, do something
body: <p>How can I check whether a ActiveRecord::Base.transaction succeded?</p>
  
  <p>I want the rollback to happen if something goes wrong, but I also want to make sure that if the transaction has succeeded I do some extra logic. Here is the code:</p>
  
  <pre><code>#...
  ActiveRecord::Base.transaction do
    user_id = existing_ids.last || User.create(phone: phone_number)
    homes.update_all(user_id: user_id)
  end
  
  if transaction_was_success
    # do something
  else 
    # do something else
  end
  </code></pre>