Introducing activerecord-transactionable
Properly Implement ActiveRecord Transactions Provides a method, transaction_wrapper at the class and instance levels that can be used instead of ActiveRecord#transaction. Enables you to do transactions properly, with custom rescues and retry, including with or without locking.
Installation Add this line to your application’s Gemfile:
gem 'activerecord-transactionable' And then execute:
$ bundle Or install it yourself as:
$ gem install activerecord-transactionable Usage class Car < ActiveRecord::Base include Activerecord::Transactionable # Note lowercase "r" in Activerecord (different namespace than rails' module) validates_presence_of :name end When creating, saving, deleting within the transaction make sure to use the bang methods (!