Class: ThinkFeelDoDashboard::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/think_feel_do_dashboard/users_controller.rb

Overview

Allows for the creation, updating, and deletion of users

Instance Method Summary collapse

Instance Method Details

#createObject

POST /think_feel_do_dashboard/users



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/think_feel_do_dashboard/users_controller.rb', line 18

def create
  @user = User.new(user_params.except(:user_roles))
  authorize! :create, @user
  build_user_roles(params)

  if @user.save
    redirect_to @user,
                notice: "User was successfully created."
  else
    render :new
  end
end

#destroyObject

DELETE /think_feel_do_dashboard/users/1



53
54
55
56
57
# File 'app/controllers/think_feel_do_dashboard/users_controller.rb', line 53

def destroy
  @user.destroy
  redirect_to users_url,
              notice: "User was successfully destroyed."
end

#editObject

GET /think_feel_do_dashboard/users/1/edit



36
37
# File 'app/controllers/think_feel_do_dashboard/users_controller.rb', line 36

def edit
end

#indexObject

GET /think_feel_do_dashboard/users



10
11
# File 'app/controllers/think_feel_do_dashboard/users_controller.rb', line 10

def index
end

#newObject

GET /think_feel_do_dashboard/users/new



14
15
# File 'app/controllers/think_feel_do_dashboard/users_controller.rb', line 14

def new
end

#showObject

GET /think_feel_do_dashboard/users/1



32
33
# File 'app/controllers/think_feel_do_dashboard/users_controller.rb', line 32

def show
end

#updateObject

PATCH/PUT /think_feel_do_dashboard/users/1



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/think_feel_do_dashboard/users_controller.rb', line 40

def update
  build_user_roles(params)
  if @user.update(user_params.except(:user_roles))
     @user, bypass: true if @user == current_user
    redirect_to user_path(@user),
                notice: "User was successfully updated.",
                only: true
  else
    render :edit
  end
end