Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UsersController
- Defined in:
- lib/generators/auth/templates/users_controller.rb
Overview
backend_authentication > app > controllers > users_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /users.
-
#destroy ⇒ Object
DELETE /users/username.
-
#index ⇒ Object
GET /users.
-
#show ⇒ Object
GET /users/username.
-
#update ⇒ Object
PUT /users/username.
Instance Method Details
#create ⇒ Object
POST /users
19 20 21 22 23 24 25 26 27 |
# File 'lib/generators/auth/templates/users_controller.rb', line 19 def create @user = User.new(user_params) if @user.save render json: @user, status: :created else render json: { errors: @user.errors. }, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /users/username
38 39 40 |
# File 'lib/generators/auth/templates/users_controller.rb', line 38 def destroy @user.destroy end |
#index ⇒ Object
GET /users
8 9 10 11 |
# File 'lib/generators/auth/templates/users_controller.rb', line 8 def index @users = User.all render json: @users, status: :ok end |
#show ⇒ Object
GET /users/username
14 15 16 |
# File 'lib/generators/auth/templates/users_controller.rb', line 14 def show render json: @user, status: :ok end |
#update ⇒ Object
PUT /users/username
30 31 32 33 34 35 |
# File 'lib/generators/auth/templates/users_controller.rb', line 30 def update unless @user.update(user_params) render json: { errors: @user.errors. }, status: :unprocessable_entity end end |