Permalink
Browse files

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

  • Loading branch information...
1 parent d2db917 commit 7f64e472772293a3a5bbf4a435d937dabd98ed92 @tenderlove tenderlove committed Oct 7, 2011
@@ -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
justinfrench
justinfrench Oct 25, 2011 Contributor

@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
tenderlove Oct 25, 2011 Owner

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

justinfrench
justinfrench Oct 25, 2011 Contributor

Outstanding responsiveness :D

drogus
drogus Dec 20, 2011 Member

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

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])
@@ -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>"

0 comments on commit 7f64e47

Please sign in to comment.