Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Ensure controller isn't leaked in ActiveController around filter #112

wants to merge 1 commit into from

3 participants


I found that in some cases the after callback was not being executed in audited. This had the side effect of leaking self.controller in tests and causing warden to show random failures. I changed the before/after callbacks to be an around callback with a begin/ensure block.

John Downey
Braintree Developer


This pull request fails (merged 4703a53 into ae4da5b).


Merged this into a new branch (pr-112 158a6db) for review by the others. Not sure exactly how to test it, but it is a legit fix, thanks so much @braintreeps.

/cc @danielmorrison @bkeepers


Picking this up in #215 where we can have Travis look after us and get other kinds of feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/audited/sweeper.rb
14 lib/audited/sweeper.rb
@@ -4,13 +4,13 @@ class Sweeper < ActiveModel::Observer
attr_accessor :controller
- def before(controller)
- self.controller = controller
- true
- end
- def after(controller)
- self.controller = nil
+ def around(controller)
+ begin
+ self.controller = controller
+ yield
+ ensure
+ self.controller = nil
+ end
def before_create(audit)
Something went wrong with that request. Please try again.