显示rails中选择选项的多级类别

时间:2014-04-24 06:49:19

标签: ruby-on-rails

目前我正在使用grouped_options_for_select来显示我的rails项目中的某些类别。代码

collection = ["North America",[["United States",["inner"]],["Canada",["inner"]]]]

<%= select_tag(::id_methods, grouped_options_for_select(collection, selected_key = " ", prompt = nil)) %>

此输出如下

North America
United States inner
 Canada
 inner

但希望输出如下

North America
 United Sates
  inner
 Canada
  inner

我该怎么做?

1 个答案:

答案 0 :(得分:0)

试试这个: -

collection = ["North America",["United States",["inner"]],["Canada",["inner"]]]

<%= select_tag(:id_methods, grouped_options_for_select(collection, selected_key = " ", prompt = nil)) %>