Skip to content

Instantly share code, notes, and snippets.

@kookster
Created December 14, 2011 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kookster/1477287 to your computer and use it in GitHub Desktop.
Save kookster/1477287 to your computer and use it in GitHub Desktop.
# 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