aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2005-09-08 12:08:24 +0000
committerNicholas Seckar <nseckar@gmail.com>2005-09-08 12:08:24 +0000
commitbf92aacf40f946432dbe3c294e26b5516637b8a4 (patch)
treecfed0a6a56db5c04239f0b56581f7a36cb2f1854 /actionpack/lib
parent689cca132a7da77c80637a938740f40277384fe9 (diff)
downloadrails-bf92aacf40f946432dbe3c294e26b5516637b8a4.tar.gz
rails-bf92aacf40f946432dbe3c294e26b5516637b8a4.tar.bz2
rails-bf92aacf40f946432dbe3c294e26b5516637b8a4.zip
Avoid extending view instance with helper modules each request. Closes #1979
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2152 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/base.rb21
-rw-r--r--actionpack/lib/action_controller/helpers.rb13
2 files changed, 16 insertions, 18 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 5f4cd5a932..5fbbab8647 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -784,13 +784,24 @@ module ActionController #:nodoc:
end
private
- def initialize_template_class(response)
- begin
- response.template = template_class.new(template_root, {}, self)
- rescue
- raise "You must assign a template class through ActionController.template_class= before processing a request"
+ def self.view_class
+ unless @view_class
+ # create a new class based on the default template class and include helper methods
+ logger.debug "defining view class for #{name}" if logger
+ @view_class = Class.new(ActionView::Base)
+ @view_class.send(:include, master_helper_module)
end
+ @view_class
+ end
+
+ def self.view_root
+ @view_root ||= template_root
+ end
+
+ def initialize_template_class(response)
+ raise "You must assign a template class through ActionController.template_class= before processing a request" unless @@template_class
+ response.template = self.class.view_class.new(self.class.view_root, {}, self)
@performed_render = @performed_redirect = false
end
diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb
index 86653e4f06..df381079eb 100644
--- a/actionpack/lib/action_controller/helpers.rb
+++ b/actionpack/lib/action_controller/helpers.rb
@@ -16,11 +16,6 @@ module ActionController #:nodoc:
alias_method :inherited_without_helper, :inherited
alias_method :inherited, :inherited_with_helper
end
-
- # Wrap initialize_template_class to extend new template class
- # instances with the master helper module.
- alias_method :initialize_template_class_without_helper, :initialize_template_class
- alias_method :initialize_template_class, :initialize_template_class_with_helper
end
end
@@ -124,13 +119,5 @@ module ActionController #:nodoc:
end
end
end
-
- private
- # Extend the template class instance with our controller's helper module.
- def initialize_template_class_with_helper(response)
- returning(initialize_template_class_without_helper(response)) do
- response.template.extend self.class.master_helper_module
- end
- end
end
end