module Geri module Admin class AdminUsersController < AdminController def index @admin_users = AdminUser.all end def new @admin_user = AdminUser.new end def edit @admin_user = AdminUser.find(params[:id]) end def update @admin_user = AdminUser.find(params[:id]) if @admin_user .update_attributes(current_user == @admin_user ? admin_user_params_with_password : admin_user_params) flash[:success] = 'The Admin User was successfully updated.' return redirect_to edit_admin_admin_user_path(@admin_user) end render :edit end def create @admin_user = AdminUser.new(admin_user_params) if @admin_user.save flash[:success] = 'The Admin User was sucessfully created, an email confirmation has been sent with ' + 'instructions for setting their password!' return redirect_to admin_admin_users_path end render :new end def destroy @admin_user = AdminUser.find(params[:id]) @admin_user.delete flash[:success] = 'The Admin User was successfully deleted.' redirect_to admin_admin_users_path end private def admin_user_params params.require(:admin_user).permit(:email, :first_name, :last_name) end def admin_user_params_with_password params.require(:admin_user).permit(:email, :first_name, :last_name, :password, :password_confirmation) end end end end