mardi 10 mai 2016

How To Add Multiple Roles Using Rails Form and Role Model Gem

Hello i have a Roles app where a user can have multiple roles. I am using Roles Model Gem. As you can see below:

4.2.5@2.2.4 (main)> User.valid_roles
=> [
    [0] :admin,
    [1] :report_writer,
    [2] :candidate,
    [3] :client_contact
]

I would like a check box form that can select multiple roles for the user. I've been trying for an hour and can't figure it out. Can anyone help?

Here is the form

%h1 Edit User

= form_for @user, url: admin_user_path(@user) do |f|

.form-group
  = f.label :first_name
  = f.text_field :first_name

.form-group
  = f.label :last_name
  = f.text_field :last_name

.form-group
  = f.label :email
  = f.text_field :email

.form-group
  = f.label :password
  = f.password_field :password

.form-actions
  = link_to "Cancel", admin_users_path, class: "btn btn-grey"
  = f.submit class: "btn btn-primary pull-right"

Aucun commentaire:

Enregistrer un commentaire