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
Original file line number Diff line number Diff line change
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
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
Original file line number Diff line number Diff line change
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.