Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

just check to see that the first item in the list is an array

  • Loading branch information...
commit 7f64e472772293a3a5bbf4a435d937dabd98ed92 1 parent d2db917
@tenderlove tenderlove authored
View
2  actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -579,7 +579,7 @@ class InstanceTag #:nodoc:
def to_select_tag(choices, options, html_options)
selected_value = options.has_key?(:selected) ? options[:selected] : value(object)
- if !choices.empty? && choices.try(:first).try(:second).respond_to?(:each)
+ if !choices.empty? && Array === choices.first

@adrianpike says this is breaking his codes in the case of [['label','id'],['label2','id2']…], which he was doing through Formtastic, but I think it's an issue either way.

@tenderlove Owner

Yup. We're working to clear it up. :-)

Outstanding responsiveness :D

@drogus Collaborator
drogus added a note

@tenderlove please also close #4048 when you're done, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
option_tags = grouped_options_for_select(choices, :selected => selected_value, :disabled => options[:disabled])
else
option_tags = options_for_select(choices, :selected => selected_value, :disabled => options[:disabled])
View
9 actionpack/test/template/form_options_helper_test.rb
@@ -587,6 +587,15 @@ def test_select_with_prompt_and_blank
)
end
+ def test_empty
+ @post = Post.new
+ @post.category = ""
+ assert_dom_equal(
+ "<select id=\"post_category\" name=\"post[category]\"><option value=\"\">Please select</option>\n<option value=\"\"></option>\n</select>",
+ select("post", "category", [], :prompt => true, :include_blank => true)
+ )
+ end
+
def test_select_with_selected_value
@post = Post.new
@post.category = "<mus>"
Please sign in to comment.
Something went wrong with that request. Please try again.