From 6cd542df7a006dfbd232db14e2d96daf29d10d0f Mon Sep 17 00:00:00 2001 From: "m. simon borg" Date: Wed, 10 May 2017 14:59:11 -0400 Subject: [PATCH] use before_action only for Rails >= 5 conditional branch on `Rails::VERSION::MAJOR` for backwards compatibility --- app/controllers/impressionist_controller.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/impressionist_controller.rb b/app/controllers/impressionist_controller.rb index 4e21621..2fee16a 100644 --- a/app/controllers/impressionist_controller.rb +++ b/app/controllers/impressionist_controller.rb @@ -3,13 +3,21 @@ require 'digest/sha2' module ImpressionistController module ClassMethods def impressionist(opts={}) - before_action { |c| c.impressionist_subapp_filter(opts) } + if Rails::VERSION::MAJOR >= 5 + before_action { |c| c.impressionist_subapp_filter(opts) } + else + before_filter { |c| c.impressionist_subapp_filter(opts) } + end end end module InstanceMethods def self.included(base) - base.before_action :impressionist_app_filter + if Rails::VERSION::MAJOR >= 5 + base.before_action :impressionist_app_filter + else + base.before_filter :impressionist_app_filter + end end def impressionist(obj,message=nil,opts={})