Merge pull request #213 from carlosantoniodasilva/railtie-extension-load

Include view and helper extensions in current context
This commit is contained in:
Steve Klabnik 2012-05-28 07:06:58 -07:00
commit 5756d83ed0
3 changed files with 7 additions and 9 deletions

View File

@ -36,13 +36,13 @@ module Draper
initializer "draper.extend_action_controller_base" do |app| initializer "draper.extend_action_controller_base" do |app|
ActiveSupport.on_load(:action_controller) do ActiveSupport.on_load(:action_controller) do
Draper::System.setup(:action_controller) Draper::System.setup(self)
end end
end end
initializer "draper.extend_action_mailer_base" do |app| initializer "draper.extend_action_mailer_base" do |app|
ActiveSupport.on_load(:action_mailer) do ActiveSupport.on_load(:action_mailer) do
Draper::System.setup(:action_mailer) Draper::System.setup(self)
end end
end end

View File

@ -10,11 +10,9 @@ module Draper
end end
def self.setup(component) def self.setup(component)
if component == :action_controller component.class_eval do
ActionController::Base.send(:include, Draper::ViewContextFilter) include Draper::ViewContextFilter
ActionController::Base.extend(Draper::HelperSupport) extend Draper::HelperSupport unless defined?(::ActionMailer) && self.is_a?(::ActionMailer::Base)
elsif component == :action_mailer
ActionMailer::Base.send(:include, Draper::ViewContextFilter)
end end
end end
end end

View File

@ -9,11 +9,11 @@ module ActionController
def self.before_filter(name) def self.before_filter(name)
@@before_filters << name @@before_filters << name
end end
Draper::System.setup(self)
end end
end end
Draper::System.setup(:action_controller)
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
extend ActionView::Helpers extend ActionView::Helpers
extend ActionView::Helpers::TagHelper extend ActionView::Helpers::TagHelper