mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #22279 from yui-knk/fix_object_partial_false
Respect value of `:object` if `:object` is false when rendering
This commit is contained in:
commit
c7368fd86d
4 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
* Respect value of `:object` if `:object` is false when rendering.
|
||||
|
||||
Fixes #22260.
|
||||
|
||||
*Yuichiro Kaneko*
|
||||
|
||||
* Generate `week_field` input values using a 1-based index and not a 0-based index
|
||||
as per the W3 spec: http://www.w3.org/TR/html-markup/datatypes.html#form.data.week
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ module ActionView
|
|||
layout = find_template(layout.to_s, @template_keys)
|
||||
end
|
||||
|
||||
object ||= locals[as]
|
||||
object = locals[as] if object.nil? # Respect object when object is false
|
||||
locals[as] = object if @has_object
|
||||
|
||||
content = @template.render(view, locals) do |*name|
|
||||
|
|
1
actionview/test/fixtures/test/_klass.erb
vendored
Normal file
1
actionview/test/fixtures/test/_klass.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<%= klass.class.name %>
|
|
@ -247,6 +247,8 @@ module RenderTestCases
|
|||
|
||||
def test_render_object
|
||||
assert_equal "Hello: david", @view.render(:partial => "test/customer", :object => Customer.new("david"))
|
||||
assert_equal "FalseClass", @view.render(:partial => "test/klass", :object => false)
|
||||
assert_equal "NilClass", @view.render(:partial => "test/klass", :object => nil)
|
||||
end
|
||||
|
||||
def test_render_object_with_array
|
||||
|
|
Loading…
Reference in a new issue