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

Était-ce utile?

La 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 %>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top