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.
-
#show ⇒ Object
GET /posts/1.
-
#update ⇒ Object
PATCH/PUT /posts/1.
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
POST /posts
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/notee/users_controller.rb', line 22 def create @user = User.new(user_params) @user.file = user_params[:profile_img] 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
47 48 49 50 |
# File 'app/controllers/notee/users_controller.rb', line 47 def destroy @user.destroy render json: { status: 'success' } end |
#index ⇒ Object
GET /users
11 12 13 14 |
# File 'app/controllers/notee/users_controller.rb', line 11 def index @users = User.all.order(updated_at: :desc) render json: { status: 'success', users: @users } end |
#show ⇒ Object
GET /posts/1
17 18 19 |
# File 'app/controllers/notee/users_controller.rb', line 17 def show render json: { status: 'success', user: @user } end |
#update ⇒ Object
PATCH/PUT /posts/1
35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/notee/users_controller.rb', line 35 def update @user.file = user_params[:profile_img] 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 |