How to get multiple fields for options_from_collection_for_select

You can define on your model:

def name; "#{first_name} #{last_name}";end

and use:

options_from_collection_for_select(@customers, :id, :name)


This can also be done in this way, you don't need to write a method in your model.

options_from_collections_for_select(
  @customers, :id, ->(ob) { "#{ob.first_name} #{ob.last_name}" }
)

add method full_name in your model :

def full_name
   "#{first_name} #{last_name}"
end

and use this :

options_from_collection_for_select(@customers, :id, :full_name)

Hope this will help.