1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Respect value of :object if :object is false when rendering

This commit fixes the bug convering `false` to `locals[as]` when
`options[:object]` is `false` (close #22260).
This commit is contained in:
yui-knk 2015-11-13 11:41:24 +09:00
parent 0db310586a
commit 429bd260c1
4 changed files with 10 additions and 1 deletions

View file

@ -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

View file

@ -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|

View file

@ -0,0 +1 @@
<%= klass.class.name %>

View file

@ -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