From 96250c45219bc4b933356e9831fec5dbff8fa893 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Thu, 15 Sep 2016 16:11:44 -0500 Subject: [PATCH] admin can assign reviewrs to quiz --- app/controllers/admin/user_controller.rb | 2 +- app/views/admin/user/_form.html.erb | 7 +++++++ app/views/admin/user/view.html.erb | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/user_controller.rb b/app/controllers/admin/user_controller.rb index eea95ab..f344909 100644 --- a/app/controllers/admin/user_controller.rb +++ b/app/controllers/admin/user_controller.rb @@ -45,7 +45,7 @@ module Admin private def user_params - params.require(:user).permit(:name, :email, :role, :password) + params.require(:user).permit(:name, :email, :role, :password, quiz_ids: []) end end end diff --git a/app/views/admin/user/_form.html.erb b/app/views/admin/user/_form.html.erb index 7b254c0..c3b5266 100644 --- a/app/views/admin/user/_form.html.erb +++ b/app/views/admin/user/_form.html.erb @@ -15,5 +15,12 @@ <%= form.select :role, admin_role_options(user.role), include_blank: false %> + <%= form.collection_check_boxes(:quiz_ids, Quiz.all, :id, :name, {}, {class: 'checkbox'}) do | quiz | %> +
+ <%= quiz.check_box( checked: user.quizzes.include?(quiz.object)) %> + <%= quiz.label %> +
+ <% end %> + <%= form.submit %> <% end %> diff --git a/app/views/admin/user/view.html.erb b/app/views/admin/user/view.html.erb index 0bd3f52..9c5ec88 100644 --- a/app/views/admin/user/view.html.erb +++ b/app/views/admin/user/view.html.erb @@ -5,4 +5,12 @@

<%= @user.name %>

<%= mail_to(@user.email) %>

<%= @user.role %>

+ +

Quizzes:

+ + <%= link_to('Edit', admin_edit_user_path(@user.to_i), { class: 'btn' }) %>