Prompt in select_tag

后端 未结 4 651
醉话见心
醉话见心 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:23

    Very simple:

    select(:user, :country, options_for_select(@COUNTRIES), :prompt=>true)
    

    For the prompt "Please select", or this for your custom text:

    select(:user, :country, options_for_select(@COUNTRIES), :prompt=>"Select country")
    

    Also note that @COUNTRIES is wrong, an instance variable should be lowercase - @countries, a contant would just be COUNTRIES.

提交回复
热议问题