-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a railtie for Audited::Sweeper's ActiveSupport.on_load hook
This prevents loading ActionController::API before Rails itself has loaded it.
- Loading branch information
1 parent
4ad3a9c
commit 0a33e4f
Showing
4 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Audited | ||
class Railtie < Rails::Railtie | ||
initializer "audited.sweeper" do | ||
ActiveSupport.on_load(:action_controller) do | ||
if defined?(ActionController::Base) | ||
ActionController::Base.around_action Audited::Sweeper.new | ||
end | ||
if defined?(ActionController::API) | ||
ActionController::API.around_action Audited::Sweeper.new | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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