diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 8e1d7a0..9680942 100755 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -2,7 +2,7 @@ class AdminController < ApplicationController before_action :administrative, if: :admin_param, except: [:get_user] skip_before_action :has_info - layout false, only: [:get_all_users, :get_user] + layout false, only: [:get_all_users] def dashboard end @@ -38,10 +38,11 @@ class AdminController < ApplicationController pass = params[:user][:password] user.password = pass if !(pass.blank?) user.save! - message = true - end - respond_to do |format| - format.json { render json: { msg: message ? "success" : "failure"} } + flash[:success] = "User updated successfully" + redirect_to admin_get_all_users_path(current_user.id) + else + flash[:error] = "User not found" + redirect_to admin_get_all_users_path(current_user.id) end end @@ -51,11 +52,11 @@ class AdminController < ApplicationController # Call destroy here so that all association records w/ id are destroyed as well # Example user.retirement records would be destroyed user.destroy - message = true - end - respond_to do |format| - format.json { render json: { msg: message ? "success" : "failure"} } + flash[:success] = "User deleted successfully" + else + flash[:error] = "Cannot delete this user" end + redirect_to admin_get_all_users_path(current_user.id) end private diff --git a/app/views/admin/get_all_users.html.erb b/app/views/admin/get_all_users.html.erb index 25afe4d..d262be1 100755 --- a/app/views/admin/get_all_users.html.erb +++ b/app/views/admin/get_all_users.html.erb @@ -29,59 +29,18 @@ <%= u.admin ? %{ - <%= link_to "Edit", "#", {:onClick => "javascript:openEditModal(#{u.id}); return false;", :role => "button", :style => "width:70px", :class => "btn btn-inverse"}%> + <%= link_to "Edit", admin_get_user_path(u.id), {:style => "width:70px", :class => "btn btn-inverse"}%> <% end %> -
+ +