diff options
author | Sam Stephenson <sam@37signals.com> | 2005-10-10 20:35:13 +0000 |
---|---|---|
committer | Sam Stephenson <sam@37signals.com> | 2005-10-10 20:35:13 +0000 |
commit | 0886bb391d97ec96d3028d5cac93ce2f7f8467e6 (patch) | |
tree | 9eb71c40c2f609d71be7032f636d4b11b8bd882a /actionpack/lib | |
parent | e3655ef733f7f69a4b1175cd6843f8bfe4c32f5d (diff) | |
download | rails-0886bb391d97ec96d3028d5cac93ce2f7f8467e6.tar.gz rails-0886bb391d97ec96d3028d5cac93ce2f7f8467e6.tar.bz2 rails-0886bb391d97ec96d3028d5cac93ce2f7f8467e6.zip |
Fixed that an instance variable with the same name as a partial should be implicitly passed as the partial :object. Closes #2269.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2522 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/partials.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb index 998956979d..21292161ea 100644 --- a/actionpack/lib/action_view/partials.rb +++ b/actionpack/lib/action_view/partials.rb @@ -52,7 +52,7 @@ module ActionView local_assigns = extract_local_assigns(local_assigns, deprecated_local_assigns) local_assigns = local_assigns ? local_assigns.clone : {} add_counter_to_local_assigns!(partial_name, local_assigns) - local_assigns[partial_name.intern] ||= object.is_a?(ActionView::Base::ObjectWrapper) ? object.value : object + add_object_to_local_assigns!(partial_name, local_assigns, object) ActionController::Base.benchmark("Rendered #{path}/_#{partial_name}", Logger::DEBUG, false) do render("#{path}/_#{partial_name}", local_assigns) @@ -111,5 +111,10 @@ module ActionView counter_name = partial_counter_name(partial_name) local_assigns[counter_name] = 1 unless local_assigns.has_key?(counter_name) end + + def add_object_to_local_assigns!(partial_name, local_assigns, object) + local_assigns[partial_name.intern] ||= object.is_a?(ActionView::Base::ObjectWrapper) ? object.value : object + local_assigns[partial_name.intern] ||= controller.instance_variable_get("@#{partial_name}") + end end end |