Created
December 14, 2011 16:25
-
-
Save kookster/1477287 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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