0

如何为使用closure_tree gem的模型实现grouped_collection_select

我有 Location 模型,它有 name 和 parent_id 属性。我想做这样的事情。

<select name="locations">
  <optgroup label="Office">
    <option value="3">Office Table 1</option>
    <option value="4">Office Table 2</option>
  </optgroup>
  <optgroup label="Lab">
    <option value="5">Another Door 1</option>
    <option value="6">Another Door 2</option>
    <option value="7">Another Door 3</option>
    <option value="8">Another Door 4</option>
    <option value="11">Another Door 5</option>
  </optgroup>
  ⋮
</select>

4

0 回答 0