Select sex with Enum

Asked

Viewed 123 times

1

I made the field select sex that 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 I can’t add sex selection, anyone? = D

1 answer

1


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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.