Reputation: 304
I'm using Devise
within Rails 5
and have added Enum/roles
(Consumer, Designer) to the User model
. When creating a new registration, I want the user to select a role
, for which I've added a radio_button
for each value/role
:
<div id="user_role"
<% User.roles.keys.each do |role| %>
<%= f.radio_button :role, role %>
<%= f.label role.to_sym %>
<% end %>
</div>
It's showing the labels
of both roles, but only the radio_button
for the last role. Here are the roles defined in the User model
:
enum role: [:consumer, :designer]
Any ideas on what I'm doing wrong here?
Upvotes: 0
Views: 106
Reputation: 330
try to this way
<div id="user_role">
<% User.roles.keys.each do |role| %>
<%= f.radio_button :role, role %>
<%= f.label role.to_sym %>
<% end %>
</div>
or
<div id="user_role">
<% User.roles.each do |role| %>
<%= f.radio_button :role, role %>
<%= f.label role[0] %>
<% end %>
</div>
it's working fine in my local.I hope it's will be help you.
Upvotes: 1