DEV Community

Discussion on: How to use transactions to unclutter your Rails controllers

Collapse
 
eugzol profile image
Eugene Zolotarev

What if your sms service failed? You render 'new' action as if nothing has happened, meanwhile Lead is persisted in the database and in the remote system, right? Then user sends form once again, and you have one more Lead in the db and in remote system. Am I missing something?

Collapse
 
mercier_remi profile image
Rémi Mercier

In the transaction has it's written above, yes. This is what would happen.

I'd include a first step that checks if the new lead already exists in the DB and branch out if that's the case. This really depends on your business logic. :)