How to get multiple fields for options_from_collection_for_select

后端 未结 3 1730
你的背包
你的背包 2021-01-17 11:40

I have the following in a select_tag. It works fine. (I\'m using select_tag because it is for a search not tied to a model.)

options_from_collection_for_sele         


        
3条回答
  •  北海茫月
    2021-01-17 12:05

    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.

提交回复
热议问题