Reputation: 689
Sorry for stupid question but I dont understand how to use check_box helper in rails. I read the documentation, but did not understand how create ckeckbox in form
for user[:role]
with params customer
and provider
(and maybe admin
)
Upvotes: 0
Views: 88
Reputation: 576
There is an example. It should works for scaffolded User model with :role atribute.
<% for role in %w(customer provider admin) %>
<p>
<%= check_box_tag "role", role, (params[:role] && params[:role].include?(role)) %>
<%=h role %>
</p>
<% end %>
Upvotes: 1
Reputation: 586
first read and understand the brief Ganesh pointed out. If user can have only one role, you need radio buttons or select list. For multiple roles, you need a Role model and check boxes.
Upvotes: 1