From 71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 18 Mar 2010 15:52:43 -0700 Subject: All tests pass without memoizing view_context --- actionpack/lib/abstract_controller/rendering.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/abstract_controller/rendering.rb') diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 16664098e5..eec7e520fa 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -32,7 +32,6 @@ module AbstractController module Rendering extend ActiveSupport::Concern - include AbstractController::Assigns include AbstractController::ViewPaths # Overwrite process to setup I18n proxy. @@ -53,7 +52,8 @@ module AbstractController # # Override this method in a module to change the default behavior. def view_context - @_view_context ||= ActionView::Base.for_controller(self) + klass = ActionView::Base.for_controller(self) + klass.new(lookup_context, view_assigns, self) end # Normalize arguments, options and then delegates render_to_body and @@ -82,7 +82,6 @@ module AbstractController # Find and renders a template based on the options given. # :api: private def _render_template(options) #:nodoc: - _evaluate_assigns(view_context) view_context.render(options) end @@ -105,6 +104,17 @@ module AbstractController private + # This method should return a hash with assigns. + # You can overwrite this configuration per controller. + # :api: public + def view_assigns + hash = {} + variables = instance_variable_names + variables -= protected_instance_variables if respond_to?(:protected_instance_variables) + variables.each { |name| hash[name.to_s[1..-1]] = instance_variable_get(name) } + hash + end + # Normalize options by converting render "foo" to render :action => "foo" and # render "foo/bar" to render :file => "foo/bar". def _normalize_args(action=nil, options={}) -- cgit v1.2.3