lib/react/rails/controller_lifecycle.rb in react-rails-1.5.0 vs lib/react/rails/controller_lifecycle.rb in react-rails-1.6.0
- old
+ new
@@ -2,12 +2,14 @@
module Rails
module ControllerLifecycle
extend ActiveSupport::Concern
included do
- # use old names to support Rails 3
- before_filter :setup_react_component_helper
- after_filter :teardown_react_component_helper
+ # use both names to support Rails 3..5
+ before_action_with_fallback = respond_to?(:before_action) ? :before_action : :before_filter
+ after_action_with_fallback = respond_to?(:after_action) ? :after_action : :after_filter
+ public_send(before_action_with_fallback, :setup_react_component_helper)
+ public_send(after_action_with_fallback, :teardown_react_component_helper)
attr_reader :__react_component_helper
end
def setup_react_component_helper
new_helper = React::Rails::ViewHelper.helper_implementation_class.new