Skip to content

Commit e980a8a

Browse files
author
Robert Mosolgo
committed
Merge pull request #456 from danott/handle-deprecated-filter-methods
Support controller callbacks for Rails 3..5
2 parents a75dac3 + 07e0e81 commit e980a8a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/react/rails/controller_lifecycle.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ module ControllerLifecycle
44
extend ActiveSupport::Concern
55

66
included do
7-
# use old names to support Rails 3
8-
before_filter :setup_react_component_helper
9-
after_filter :teardown_react_component_helper
7+
# use both names to support Rails 3..5
8+
before_action_with_fallback = respond_to?(:before_action) ? :before_action : :before_filter
9+
after_action_with_fallback = respond_to?(:after_action) ? :after_action : :after_filter
10+
public_send(before_action_with_fallback, :setup_react_component_helper)
11+
public_send(after_action_with_fallback, :teardown_react_component_helper)
1012
attr_reader :__react_component_helper
1113
end
1214

0 commit comments

Comments
 (0)