Class: Notee::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Notee::UsersController
- Defined in:
- app/controllers/notee/users_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /posts.
-
#destroy ⇒ Object
DELETE /posts/1.
-
#index ⇒ Object
GET /users.
- #mypage ⇒ Object
-
#show ⇒ Object
GET /posts/1.
-
#update ⇒ Object
PATCH/PUT /posts/1.
- #update_password ⇒ Object
Methods inherited from ApplicationController
#restrict_access_json, #set_request_filter
Instance Method Details
#create ⇒ Object
POST /posts
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/notee/users_controller.rb', line 28 def create @user = User.new(user_params) respond_to do |format| if @user.save format.json { render json: @user, status: 200 } else format.json { render json: @user.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /posts/1
62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/notee/users_controller.rb', line 62 def destroy respond_to do |format| if @user.update(is_deleted: true) format.json { render json: @user, status: 200 } else format.json { render json: @user.errors, status: :internal_server_error } end end end |
#index ⇒ Object
GET /users
12 13 14 15 |
# File 'app/controllers/notee/users_controller.rb', line 12 def index @users = User.where(is_deleted: false).order(updated_at: :desc) render json: { status: 'success', users: @users } end |
#mypage ⇒ Object
22 23 24 25 |
# File 'app/controllers/notee/users_controller.rb', line 22 def mypage @user = Token.find_by(access_token: session[:access_token]).user render json: { status: 'success', user: @user } end |
#show ⇒ Object
GET /posts/1
18 19 20 |
# File 'app/controllers/notee/users_controller.rb', line 18 def show render json: { status: 'success', user: @user } end |
#update ⇒ Object
PATCH/PUT /posts/1
40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/notee/users_controller.rb', line 40 def update respond_to do |format| if @user.update(user_params) format.json { render json: @user, status: 200 } else format.json { render json: @user.errors, status: :unprocessable_entity } end end end |
#update_password ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/notee/users_controller.rb', line 50 def update_password @user = Token.find_by(access_token: session[:access_token]).user respond_to do |format| if @user.update_password(user_params) format.json { render json: @user, status: 200 } else format.json { render json: @user.errors, status: :unprocessable_entity } end end end |