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

47 lines
711 B
Ruby
Raw Normal View History

2015-10-08 15:18:21 -04:00
class UsersController < ApplicationController
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)
redirect_to users_path, notice: 'User was updated'
else
render :edit
end
end
def destroy
authorize @user
@user.destroy
redirect_to users_path, notice: 'User was deleted'
end
private
def user_params
params.require(:user).permit(role_ids: [])
end
def set_user
@user = User.find(params[:id])
end
end