Class: PushType::Api::UsersController

Inherits:
PushType::ApiController show all
Defined in:
app/controllers/push_type/api/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
# File 'app/controllers/push_type/api/users_controller.rb', line 16

def create
  if @user.save
    render :show, status: :created
  else
    render json: { errors: @user.errors }, status: :unprocessable_entity
  end
end

#destroyObject



32
33
34
35
36
37
38
39
# File 'app/controllers/push_type/api/users_controller.rb', line 32

def destroy
  if @user != push_type_user
    @user.destroy
    head :no_content
  else
    head :bad_request
  end
end

#indexObject



9
10
11
# File 'app/controllers/push_type/api/users_controller.rb', line 9

def index
  @users = user_scope.page(params[:page]).per(30)
end

#showObject



13
14
# File 'app/controllers/push_type/api/users_controller.rb', line 13

def show
end

#updateObject



24
25
26
27
28
29
30
# File 'app/controllers/push_type/api/users_controller.rb', line 24

def update
  if @user.update_attributes user_params_with_fields
    render :show
  else
    render json: { errors: @user.errors }, status: :unprocessable_entity
  end
end