Question

I am using the following DSL in simple_form:

<%= m.association :accessories, label_method: :full_name, value_method: :id, include_blank: false %>

I would like to re-order the dropdown list to be sorted alphabetically by :full_name

Was it helpful?

Solution

According to the simple_form readme, there's no option to do that. In order to achieve what you want to do, you can pass a collection option.

<%= m.association :accessories, collection: Accessory.order(:name), label_method: :full_name, value_method: :id, include_blank: false %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top