Skip to content

Commit

Permalink
Merge pull request #629 from jashank/master
Browse files Browse the repository at this point in the history
Switch callbacks from `_filter` to `_action`
  • Loading branch information
jaredbeck committed Oct 2, 2015
2 parents 117288f + 2c7416d commit 5a5ff94
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/paper_trail/frameworks/rails/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@ module Rails
module Controller

def self.included(base)
base.before_filter :set_paper_trail_enabled_for_controller
base.before_filter :set_paper_trail_controller_info
base.after_filter :warn_about_not_setting_whodunnit
before = [
:set_paper_trail_enabled_for_controller,
:set_paper_trail_controller_info,
]
after = [
:warn_about_not_setting_whodunnit,
]

if base.respond_to? :before_action
# Rails 4+
before.map {|sym| base.before_action sym }
after.map {|sym| base.after_action sym }
else
# Rails 3.
before.map {|sym| base.before_filter sym }
after.map {|sym| base.after_filter sym }
end
end

protected
Expand Down

0 comments on commit 5a5ff94

Please sign in to comment.