Class: UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
# File 'app/controllers/users_controller.rb', line 10

def create
  user = User.new(user_params)

  if user.save
    render json: {message: "User created successfully"}, status: :created
  else
    render json: {errors: user.errors.full_messages}, status: :bad_request
  end
end

#showObject



2
3
4
5
6
7
8
# File 'app/controllers/users_controller.rb', line 2

def show
  if current_user
    render json: { email: current_user.email, user_id: current_user.id }
  else
    render json: {}, status: :unauthorized
  end
end