Adds ability to specificy the callbacks that should be preserved. Updates authlogic callback to correct method name

Joe Peduto committed Jun 06, 2017
commit 71129efe9d4d0b18a115db4787e812319eb99b8d
Showing 3 changed files with 9 additions and 2 deletions
CHANGELOG.md +4 -0
@@ @@ -1,3 +1,7 @@
+ ## 1.6.1
+
+ - Added ability to define callbacks that should be preserved in Ahoy provided controllers
+
## 1.6.0
- Added support for Rails 5.1
app/controllers/ahoy/base_controller.rb +1 -2
@@ @@ -1,7 +1,6 @@
module Ahoy
class BaseController < ApplicationController
- # skip all filters except for authlogic
- filters = _process_action_callbacks.map(&:filter) - [:load_authlogic]
+ filters = _process_action_callbacks.map(&:filter) - Ahoy.preserve_callbacks
if Rails::VERSION::MAJOR >= 5
skip_before_action(*filters, raise: false)
skip_after_action(*filters, raise: false)
ahoy.rb b/lib/ahoy.rb +4 -0
@@ @@ -89,6 +89,10 @@ module Ahoy
mattr_accessor :api_only
self.api_only = false
+ mattr_accessor :preserve_callbacks
+ # Preserve Authlogic activation. Users of Authlogic will likely need this to properly obtain current_user.
+ self.preserve_callbacks = [:activate_authlogic]
+
mattr_accessor :protect_from_forgery
self.protect_from_forgery = false