I followed this railscast http://railscasts.com/episodes/189-embedded-association?view=comments which I think it's great but I want to handle the roles a bit differently.
I want to have a column 'roles' that stores comma delimited values, for example: "administrator, teacher" so that user has administrator and teacher roles assigned.
I would like to set that up having checkboxes.
What I currently have saves this instead: "---\n- administrator\n- teacher\n- ''\n"
How could I do that?
_form.html.erb
<div class="group">
<%= f.label :roles, "Roles", :class => :label %>
<% for role in User::ROLES %>
<%= check_box_tag "user[roles][]", role, @user.roles.include?(role) %>
<%=h role.humanize %><br />
<% end %>
<%= hidden_field_tag "user[roles][]", "" %>
</div>
user.rb
ROLES = %w[superadmin admin instructor salesperson student]