From d3cbec8283d1545dd4121cf08cff1864fb80fb01 Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Wed, 18 Dec 2013 15:23:44 -0500 Subject: [PATCH 1/2] Don't think clear! is necessary, and give before_filter a name --- lib/draper.rb | 5 +---- lib/draper/view_context.rb | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/draper.rb b/lib/draper.rb index f5b1fbc..a919ed9 100644 --- a/lib/draper.rb +++ b/lib/draper.rb @@ -32,10 +32,7 @@ module Draper extend Draper::HelperSupport extend Draper::DecoratesAssigned - before_filter do |controller| - Draper::ViewContext.clear! - Draper::ViewContext.controller = controller - end + before_filter :activate_draper end end diff --git a/lib/draper/view_context.rb b/lib/draper/view_context.rb index b49b22d..02d0ac3 100755 --- a/lib/draper/view_context.rb +++ b/lib/draper/view_context.rb @@ -10,6 +10,11 @@ module Draper end end + # Set the current controller + def activate_draper + Draper::ViewContext.controller = controller + end + # Returns the current controller. def self.controller RequestStore.store[:current_controller] From 18ddae30dde741f65f7a3adf19ded9439bd8bb36 Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Wed, 18 Dec 2013 16:06:31 -0500 Subject: [PATCH 2/2] Set the controller properly --- lib/draper/view_context.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/draper/view_context.rb b/lib/draper/view_context.rb index 02d0ac3..7f5007f 100755 --- a/lib/draper/view_context.rb +++ b/lib/draper/view_context.rb @@ -12,7 +12,7 @@ module Draper # Set the current controller def activate_draper - Draper::ViewContext.controller = controller + Draper::ViewContext.controller = self end # Returns the current controller.