How to get multiple fields for options_from_collection_for_select

后端 未结 3 1757
你的背包
你的背包 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:02

    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}" }
    )
    

提交回复
热议问题