From b3a2af7488f76db235a84d993077dbc51fa82cb4 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 28 Aug 2012 22:47:16 -0700 Subject: [PATCH] Break reliance on ActionController. Originally brought up in #249, I didn't know how to fix this. But now I do. --- lib/draper/view_context.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/draper/view_context.rb b/lib/draper/view_context.rb index 2c53fc8..edea561 100644 --- a/lib/draper/view_context.rb +++ b/lib/draper/view_context.rb @@ -1,8 +1,12 @@ module Draper module ViewContext + def self.included(controller) + @controller = controller + end + def self.current Thread.current[:current_view_context].tap do |context| - context ||= ApplicationController.new.view_context + context ||= @controller.new.view_context context.controller.request ||= ActionController::TestRequest.new context.request ||= context.controller.request context.params ||= {}