public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# 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"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.