Skip to content

Instantly share code, notes, and snippets.

@cheald
Created October 1, 2012 20:28
Show Gist options
  • Save cheald/3814222 to your computer and use it in GitHub Desktop.
Save cheald/3814222 to your computer and use it in GitHub Desktop.
diff --git a/lib/draper/railtie.rb b/lib/draper/railtie.rb
old mode 100644
new mode 100755
index 598e44f..04d35fa
--- a/lib/draper/railtie.rb
+++ b/lib/draper/railtie.rb
@@ -24,13 +24,13 @@ module Draper
initializer "draper.extend_action_controller_base" do |app|
ActiveSupport.on_load(:action_controller) do
- Draper::System.setup(self)
+ Draper::System.setup_action_controller(self)
end
end
initializer "draper.extend_action_mailer_base" do |app|
ActiveSupport.on_load(:action_mailer) do
- Draper::System.setup(self)
+ Draper::System.setup_action_mailer(self)
end
end
diff --git a/lib/draper/system.rb b/lib/draper/system.rb
old mode 100644
new mode 100755
index ff378cd..fb8b7ef
--- a/lib/draper/system.rb
+++ b/lib/draper/system.rb
@@ -1,9 +1,16 @@
module Draper
class System
- def self.setup(component)
+ def self.setup_action_controller(component)
+ component.class_eval do
+ include Draper::ViewContext
+ extend Draper::HelperSupport
+ before_filter lambda{|c| Draper::ViewContext.current = c.view_context }
+ end
+ end
+
+ def self.setup_action_mailer(component)
component.class_eval do
include Draper::ViewContext
- extend Draper::HelperSupport unless defined?(::ActionMailer) && self.is_a?(::ActionMailer::Base)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment