ruby - Nested Select in Rails -


I am working on a rail application which is items for categories .

My category model is self-connected so categories can be nested:

  class category  "Parent_id" belong_to: parent, class_name = & gt; "Category" ... end  

I have a form that allows the user to create a item , which currently selects all categories in one selection , But they all listed together:

  <% = f.label: category_id%> & Lt;% = Select: item, category_id, category.all.collect {| C | [CITAL, CID]}%>  

So the selection looks like this:

  category 2 category 2 category 3 belgs to 2 category 4 belgantoo1  

But what do I want:

  Category 1 - Category 4 Belgsto1 Category 2 - Category 3 Belgs to 2  

Is there an assistant for this? (Which would be awesome!)? If not, how can I do this?

Thank you!

To see if you want, or


Comments