lundi 1 février 2021

Sort data collection_check_boxes

I have a collection_check_boxes with custom data. In my model I have a method like this:

def label
   [social_profile.name, I18n.t(source_type_code, scope: 'enum.source_type.name')].join(' - ')
end

And in my view I have this:

= f.collection_check_boxes(:source_ids, @sources, :id, :label)

But I need to sort the data returned by my method label alphabetically. How can I do that? Thank you!




Aucun commentaire:

Enregistrer un commentaire