Class: Orchestrator::Api::UsersController

Inherits:
Orchestrator::ApiController show all
Defined in:
app/controllers/orchestrator/api/users_controller.rb

Constant Summary collapse

ADMIN_DATA =

Admins can see a little more of the users data

User::PUBLIC_DATA.dup

Instance Method Summary collapse

Methods inherited from Base

#options

Instance Method Details

#currentObject



36
37
38
# File 'app/controllers/orchestrator/api/users_controller.rb', line 36

def current
    respond_with current_user
end

#indexObject



21
22
23
24
25
26
27
# File 'app/controllers/orchestrator/api/users_controller.rb', line 21

def index
    query = @@elastic.query(params)
    results = @@elastic.search(query) do |user|
        user.as_json(ADMIN_DATA)
    end
    respond_with results
end

#showObject



29
30
31
32
33
34
# File 'app/controllers/orchestrator/api/users_controller.rb', line 29

def show
    user = User.find(id)

    # We only want to provide limited 'public' information
    respond_with user, User::PUBLIC_DATA
end

#updateObject

Requests requiring authorization have already loaded the model



43
44
45
46
47
# File 'app/controllers/orchestrator/api/users_controller.rb', line 43

def update
    @user.update_attributes(safe_params)
    @user.save
    respond_with @user
end