0

How can I implement grouped_collection_select for my model which is use closure_tree gem?

I have Location model, which is have name and parent_id attribute. I want to do something like this.

<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>
Erol Guzoğlu
  • 486
  • 6
  • 24
  • There is a question similar topic, but I can figure out. How can i do that. http://stackoverflow.com/questions/2154169/formtastic-select-with-grouping – Erol Guzoğlu Feb 07 '16 at 01:26
  • if you have 'office and 'lab' and those are ```location names``` then you need some other type of collection that would hold the ```Office Table 1``` and ```Office Table 2``` ... So where are those coming from? ie what is the name of that child table. – MilesStanfield Feb 07 '16 at 01:36
  • There is no child table. `Office` and `Office Table 1` in the same table. You can check closure_tree gem. – Erol Guzoğlu Feb 07 '16 at 02:07

0 Answers0