aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tags
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2013-09-23 17:48:23 +0300
committerBogdan Gusiev <agresso@gmail.com>2013-09-23 17:48:23 +0300
commite8e08d69c203050634c427d7978d8e1af36455b0 (patch)
treee03520e2682145e3ec7a8de2612904cd3b811aa3 /actionview/lib/action_view/helpers/tags
parented0b080cb37a420194b56a7029017ce4a1e8b408 (diff)
downloadrails-e8e08d69c203050634c427d7978d8e1af36455b0.tar.gz
rails-e8e08d69c203050634c427d7978d8e1af36455b0.tar.bz2
rails-e8e08d69c203050634c427d7978d8e1af36455b0.zip
Fix some edge cases for AV `select` helper with `:selected` option
Diffstat (limited to 'actionview/lib/action_view/helpers/tags')
-rw-r--r--actionview/lib/action_view/helpers/tags/base.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb
index 3fe3f4e9df..8607da301c 100644
--- a/actionview/lib/action_view/helpers/tags/base.rb
+++ b/actionview/lib/action_view/helpers/tags/base.rb
@@ -119,7 +119,8 @@ module ActionView
html_options = html_options.stringify_keys
add_default_name_and_id(html_options)
options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options)
- select = content_tag("select", add_options(option_tags, options, value(object)), html_options)
+ value = options.fetch(:selected) { value(object) }
+ select = content_tag("select", add_options(option_tags, options, value), html_options)
if html_options["multiple"] && options.fetch(:include_hidden, true)
tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select