Create a gist now

Instantly share code, notes, and snippets.

# make this class in lib/transactional_requests.rb, and load it on start
require 'activerecord'
class TransactionalRequests
def initialize(app)
@app = app
end
def call(env)
ActiveRecord::Base.transaction do
@app.call(env)
end
end
end
# and in the app config
config.middleware.use "TransactionalRequest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment