Prompt in select_tag

后端 未结 4 654
醉话见心
醉话见心 2021-02-07 07:31

In my application in user registration I have a country picker..

<%= select(:user, :country, options_for_select(@COUNTRIES)) %>

And I wan

4条回答
  •  梦如初夏
    2021-02-07 08:17

    collection_select(:product,
      :category_id,
      Category.all,    
      :id,    
      :title,    
      {:prompt => true}
    )
    
    collection_select(:product,    
      :category_id,    
      Category.all,    
      :id,    
      :title,    
      {:include_blank => 'Please Select'}
    )
    

    both of these result in the same html, but the first one will not include the 'Please Select' option when you return to edit the previously created Product

提交回复
热议问题