Skip to content

Commit

Permalink
just check to see that the first item in the list is an array
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 7, 2011
1 parent d2db917 commit 7f64e47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/form_options_helper.rb
Expand Up @@ -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

This comment has been minimized.

Copy link
@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.

This comment has been minimized.

Copy link
@tenderlove

tenderlove Oct 25, 2011

Author Member

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

This comment has been minimized.

Copy link
@justinfrench

justinfrench Oct 25, 2011

Contributor

Outstanding responsiveness :D

This comment has been minimized.

Copy link
@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])
Expand Down
9 changes: 9 additions & 0 deletions actionpack/test/template/form_options_helper_test.rb
Expand Up @@ -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>"
Expand Down

0 comments on commit 7f64e47

Please sign in to comment.