提交 4d2ae8a6 编写于 作者: J Jeremy Kemper

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
上级 cb1aab05
*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]
......
......@@ -187,12 +187,14 @@ def add_counter_to_local_assigns!(partial_name, local_assigns)
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
......@@ -689,12 +689,12 @@ def test_empty_partial_collection
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 @@ def test_using_layout_around_block
get :using_layout_around_block
assert_equal "Before (David)\nInside from block\nAfter", @response.body
end
end
\ No newline at end of file
end
<%= hash_object[:first_name] %>
\ No newline at end of file
<%= hash_object[:first_name] %>
<%= object[:first_name].reverse %>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册