diff options
author | Agis- <corestudiosinc@gmail.com> | 2014-10-28 23:18:58 +0200 |
---|---|---|
committer | Agis- <corestudiosinc@gmail.com> | 2014-11-25 22:26:42 +0200 |
commit | 8f7434adba492bfa52463d1eeeaf7d5cb16288f6 (patch) | |
tree | cd63dbc0b89af302931a368912242468e5229d9d | |
parent | 4426b726bfd3f7d26224c2d8ffdc3c00cd1b561a (diff) | |
download | rails-8f7434adba492bfa52463d1eeeaf7d5cb16288f6.tar.gz rails-8f7434adba492bfa52463d1eeeaf7d5cb16288f6.tar.bz2 rails-8f7434adba492bfa52463d1eeeaf7d5cb16288f6.zip |
Local vars should exist in partials for falsy `:object:` values too
c67005f221f102fe2caca231027d9b11cf630484 made the local var in partials
available only if what passed to `:object` was truthy.
For example this would not make the local variable `foo` available inside the
partial:
render partial: 'foo', object: false
Fixes #17373.
-rw-r--r-- | actionview/CHANGELOG.md | 7 | ||||
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer.rb | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 6b7adbe4a3..de65543137 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,10 @@ +* Local variable in a partial is now available even if a falsy value is + passed to `:object` when rendering a partial. + + Fixes #17373. + + *Agis Anastasopoulos* + * Add support for `:enforce_utf8` option in `form_for`. This is the same option that was added in 06388b0 to `form_tag` and allows diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index 0407632435..338ae270d2 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -366,7 +366,7 @@ module ActionView partial = options[:partial] if String === partial - @object = options[:object] + @object = options[:object] if options.has_key?(:object) @collection = collection_from_options @path = partial else @@ -506,7 +506,7 @@ module ActionView def retrieve_template_keys keys = @locals.keys - keys << @variable if @object || @collection + keys << @variable if defined?(@object) || @collection if @collection keys << @variable_counter keys << @variable_iteration |