Select sex with enum

1

I made the select gender field this way:

model:

enum sexo: [:feminino, :masculino, :desconhecido]



    def self.sexes_for_select
        sexos.keys.map{ |x| [x.humanize, x] }
    end

form:

<%= f.select :sexo, Pessoa.sexes_for_select %>

The problem is that I can not add the select sex option, anyone? = D

    
asked by anonymous 19.10.2016 / 17:32

1 answer

1

If you want to add a prompt to the select, just add this option to f.select , as follows:

<%= f.select :sexo, Grupo.sexes_for_select, prompt: 'Selecionar sexo' %>
    
19.10.2016 / 19:19