From 4d2ae8a69914217d992ed1a7e06a5d18074ae622 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 25 Oct 2007 21:32:01 +0000 Subject: Partials also set 'object' to the default partial variable. Closes #8823. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8018 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/partials.rb | 14 ++++++++------ actionpack/test/controller/new_render_test.rb | 6 +++--- actionpack/test/fixtures/test/_hash_object.erb | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 297a8aa1f1..1687f5af2f 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Partials also set 'object' to the default partial variable. #8823 [Nick Retallack, Jeremy Kemper] + * Request profiler. [Jeremy Kemper] * Disabled checkboxes don't submit a form value. #9301 [vladr, robinjfisher] diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb index 5988083091..17556b3141 100644 --- a/actionpack/lib/action_view/partials.rb +++ b/actionpack/lib/action_view/partials.rb @@ -187,12 +187,14 @@ module ActionView def add_object_to_local_assigns!(partial_name, local_assigns, object) variable_name = partial_variable_name(partial_name) - local_assigns[variable_name] ||= - if object.is_a?(ActionView::Base::ObjectWrapper) - object.value - else - object - end || controller.instance_variable_get("@#{variable_name}") + + local_assigns[:object] ||= + local_assigns[variable_name] ||= + if object.is_a?(ActionView::Base::ObjectWrapper) + object.value + else + object + end || controller.instance_variable_get("@#{variable_name}") end end end diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 0ef8ce141b..8a3013bec6 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -689,12 +689,12 @@ EOS def test_partial_with_hash_object get :partial_with_hash_object - assert_equal "Sam", @response.body + assert_equal "Sam\nmaS\n", @response.body end def test_hash_partial_collection get :partial_hash_collection - assert_equal "PratikAmy", @response.body + assert_equal "Pratik\nkitarP\nAmy\nymA\n", @response.body end def test_partial_hash_collection_with_locals @@ -829,4 +829,4 @@ EOS get :using_layout_around_block assert_equal "Before (David)\nInside from block\nAfter", @response.body end -end \ No newline at end of file +end diff --git a/actionpack/test/fixtures/test/_hash_object.erb b/actionpack/test/fixtures/test/_hash_object.erb index 037a7368d6..55c03afb27 100644 --- a/actionpack/test/fixtures/test/_hash_object.erb +++ b/actionpack/test/fixtures/test/_hash_object.erb @@ -1 +1,2 @@ -<%= hash_object[:first_name] %> \ No newline at end of file +<%= hash_object[:first_name] %> +<%= object[:first_name].reverse %> -- cgit v1.2.3