Custom fields in collection_select
Setup a custom select option text field in collection_select
Contact belongs_to Company
add a public method to your model, in this case Contact Contact.rb ( Model )
def name_and_company
self.name + " - " + self.company.name
end
Usage ( note the use of :name_and_company )
<%= form.collection_select(:contact_id, Contact.all, :id, :name_and_company ) %>
⬅️ Read previous Read next ➡️