Ruby on Rails 4.1
I am using Devise with enum role. It currently sets a defualt role when the User is created. I want to add a field to the form that creates Users to se
Since you are using Rails 4 or higher, enums are even less complicated.
Given the following enum:
enum role: {
admin: 1
}
Enums expect the HTML option attribute value
to be the enum key:
Knowing this, you can pass in the enum keys.
<%= f.select :role, User.roles.keys, {}, class: 'user-roles-select' %>
Then using CSS you can modify the appearance.
.user-roles-select option {
text-transform: capitalize;
}