In a view that I have, I am using fields_for to display form data for a relational table. However, part of this form will have select lists to choose from. I see there are lab
You are looking for select or collection_select. Both can be used in form_for or fields_for blocks. There are examples on how to use them in a form_for in the documentation
There are several select helper methods which you can use. The most common being collection_select. This is great if you have a belongs_to
association on the model and you want to use a select menu to set this.
<%= f.collection_select :category_id, Category.all, :id, :name %>
For other situations there is the more generic select method. Here you can supply an array of options you want to provide.
<%= f.select :priority, [["Low", 1], ["Medium", 2], ["High", 3]] %>
The first value in each array element is the name of the select option, the second is the value which will be assigned to the attribute.
There are many other select menus (for dates and times) but the above two should cover most situations. These methods work on both form_for
or fields_for
.