Class: UsersController

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

Overview

The users controller

Instance Method Summary collapse

Methods inherited from ApplicationController

#system

Instance Method Details

#createObject

Create a user


21
22
23
24
# File 'app/controllers/users_controller.rb', line 21

def create
  user = User.new
  user.attributes = params.require(:user).permit(:username, :email, :name, :gender, :password)
end

#destroyObject

Destroy a user


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

def destroy
  @user.destroy
end

#indexObject

Show all users


11
12
13
# File 'app/controllers/users_controller.rb', line 11

def index
  render json: User.all
end

#showObject

Show a single user


16
17
18
# File 'app/controllers/users_controller.rb', line 16

def show
  render json: @user
end

#updateObject

Update a user


27
28
29
# File 'app/controllers/users_controller.rb', line 27

def update
  @user.attributes = params.require(:user).permit(:username, :email, :name, :gender, :password)
end