Trying to figure out how concurrency is dealt with in Ruby On Rails.
How do I get a segment of code to lock on lines in the database and force rollbacks when needed?
More specificly, Is there a way to force a certain segment of code to complete totally and if not rollback? I’m looking to add history to transactions in my project and I don’t want transactions to commit without the history being saved so if the server falls between the two actions (saving the transaction and saving the history) the database may go into an illegal state.
You want to look at ActiveRecord Transactions and Pessimistic Locking.