Class: Api::UsersController

Inherits:
ApplicationController
  • Object
show all
Includes:
ActionController::Serialization, LoggedInControllerConcern
Defined in:
app/controllers/api/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#searchObject

Returns the user with matching email

‘GET /api/users/search?email=xxx`



18
19
20
21
22
23
24
25
# File 'app/controllers/api/users_controller.rb', line 18

def search
  user = User.where("email = ? AND id != ?", params[:email], @user.id).first
  if user
    render json: user
  else
    render status: :not_found
  end
end

#showObject

Renders the current user as json

‘GET /api/user/:id`



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

def show
  render json: @user
end