From 32402b62e0770cebffd31fc82ff7dc1b3cd89fdd Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Sat, 30 May 2015 16:34:49 +0300 Subject: [PATCH] Admin toggling --- app/controllers/management/users_controller.rb | 1 + app/views/management/users/index.html.slim | 9 +++++---- config/routes.rb | 6 +++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index 64b1c5c..cb1e220 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -7,6 +7,7 @@ module Management def toggle_admin @user = find_user @user.toggle_admin! + redirect_to :back end def show diff --git a/app/views/management/users/index.html.slim b/app/views/management/users/index.html.slim index d807e5f..228b1df 100644 --- a/app/views/management/users/index.html.slim +++ b/app/views/management/users/index.html.slim @@ -17,10 +17,11 @@ td= image_tag(user.profile_picture.thumb.url) td= user.name td.boolean-col - - if user.admin? - = icon 'check-square-o' - - else - = icon 'minus-square-o' + = link_to toggle_admin_management_user_path(user), method: :put do + - if user.admin? + .btn.btn-primary= icon('circle-o') + - else + .btn.btn-success= icon('dot-circle-o') td.actions div.btn-group.btn-group-sm diff --git a/config/routes.rb b/config/routes.rb index 25be034..7468272 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,7 +10,11 @@ Rails.application.routes.draw do resources :sponsorship_offers resource :call_for_participation, only: [:create, :destroy] end - resources :users + resources :users do + member do + put :toggle_admin + end + end end root 'management/conferences#index'