From a59a3db1f3ae8c6aadaa8e1ce08b05f9ad677932 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sun, 31 Aug 2008 03:44:00 +0100 Subject: Move copying ivar logic from ActionController::Base to ActionView::Base --- actionpack/lib/action_view/base.rb | 16 +++++++++------- actionpack/lib/action_view/renderable.rb | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index c65048bfa0..ce629d332a 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -343,18 +343,20 @@ module ActionView #:nodoc: private # Evaluate the local assigns and pushes them to the view. - def evaluate_assigns + def evaluate_assigns_and_ivars unless @assigns_added - assign_variables_from_controller + @assigns.each { |key, value| instance_variable_set("@#{key}", value) } + + if @controller + variables = @controller.instance_variables + variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables) + variables.each {|name| instance_variable_set(name, @controller.instance_variable_get(name)) } + end + @assigns_added = true end end - # Assigns instance variables from the controller to the view. - def assign_variables_from_controller - @assigns.each { |key, value| instance_variable_set("@#{key}", value) } - end - def set_controller_content_type(content_type) if controller.respond_to?(:response) controller.response.content_type ||= content_type diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb index fa45edd436..5d950e336e 100644 --- a/actionpack/lib/action_view/renderable.rb +++ b/actionpack/lib/action_view/renderable.rb @@ -29,7 +29,7 @@ module ActionView view._first_render ||= self view._last_render = self - view.send(:evaluate_assigns) + view.send(:evaluate_assigns_and_ivars) view.send(:set_controller_content_type, mime_type) if respond_to?(:mime_type) view.send(method_name(local_assigns), local_assigns) do |*names| -- cgit v1.2.3