Class: Orchestrator::Api::UsersController
- Inherits:
-
Orchestrator::ApiController
- Object
- ActionController::Base
- Base
- Orchestrator::ApiController
- Orchestrator::Api::UsersController
- 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
- #current ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
Requests requiring authorization have already loaded the model.
Methods inherited from Base
Instance Method Details
#current ⇒ Object
36 37 38 |
# File 'app/controllers/orchestrator/api/users_controller.rb', line 36 def current respond_with current_user end |
#index ⇒ Object
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 |
#show ⇒ Object
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 |
#update ⇒ Object
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 |