Class: Api::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Api::UsersController
- Includes:
- UsersConcern
- Defined in:
- app/controllers/api/users_controller.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
Delete your user profile.
-
#profile ⇒ Object
Return a user profile.
-
#update ⇒ Object
Update a user profile.
Instance Method Details
#destroy ⇒ Object
Delete your user profile. Can only delete the current user
Example
DELETE api/users/:id.json
HEAD OK
56 57 58 59 60 61 |
# File 'app/controllers/api/users_controller.rb', line 56 def destroy user = User.find(current_user.id) github_login = user.github_login user.destroy head :ok end |
#profile ⇒ Object
Return a user profile. Only shows the current user
Example
GET api/users/profile.json
{
"user" : {
"id" : 1,
"github_id" : 3074765,
"github_login" : "jules2689",
"last_synced_at" : "2017-02-22T15:49:32.104Z",
"created_at" : "2017-02-22T15:49:32.099Z",
"updated_at" : "2017-02-22T15:49:32.099Z"
}
}
22 23 24 |
# File 'app/controllers/api/users_controller.rb', line 22 def profile end |
#update ⇒ Object
Update a user profile. Only updates the current user
-
:personal_access_token
- The user’s personal access token -
:refresh_interval
- The refresh interval on which a sync should be initiated (while viewing the app). In milliseconds.
Example
PATCH api/users/:id.json
{ "user" : { "refresh_interval" : 60000 } }
HEAD OK
38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/api/users_controller.rb', line 38 def update if current_user.update(update_user_params) if params[:user][:regenerate_api_token] current_user.regenerate_api_token end head :ok else render json: { errors: current_user.errors..to_sentence }, status: :unprocessable_entity end end |