Class: Notee::UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /posts



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/notee/users_controller.rb', line 21

def create
  @user = User.new(user_params)
  respond_to do |format|
    if @user.save
      format.json { render json: @user, status: 200 }
    else
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /posts/1



44
45
46
47
# File 'app/controllers/notee/users_controller.rb', line 44

def destroy
  @user.destroy
  render json: { status: 'success'}
end

#indexObject

GET /users



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

def index
  @users = User.all.order(updated_at: :desc)
  render json: { status: 'success', users: @users}
end

#showObject

GET /posts/1



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

def show
  render json: { status: 'success', user: @user}
end

#updateObject

PATCH/PUT /posts/1



33
34
35
36
37
38
39
40
41
# File 'app/controllers/notee/users_controller.rb', line 33

def update
  respond_to do |format|
    if @user.update(user_params)
      format.json { render json: @user, status: 200 }
    else
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end