1
0
Fork 0
dokkan-data-rails/app/controllers/admin/users_controller.rb

47 lines
730 B
Ruby
Raw Permalink Normal View History

2015-10-09 08:17:29 -04:00
class Admin::UsersController < Admin::BaseController
2015-10-08 15:18:21 -04:00
before_action :set_user, only: [:show, :edit, :update, :destroy]
after_action :verify_authorized
def index
@users = User.all
authorize User
end
def show
authorize @user
end
def edit
authorize @user
end
def update
authorize @user
if @user.update(user_params)
2015-10-09 08:17:29 -04:00
redirect_to admin_users_path, notice: 'User was updated'
2015-10-08 15:18:21 -04:00
else
render :edit
end
end
def destroy
authorize @user
@user.destroy
2015-10-09 08:17:29 -04:00
redirect_to admin_users_path, notice: 'User was deleted'
2015-10-08 15:18:21 -04:00
end
private
def user_params
params.require(:user).permit(role_ids: [])
end
def set_user
@user = User.find(params[:id])
end
end