Class: Ecom::Core::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ecom/core/users_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #logged_in?

Instance Method Details

#activeObject



10
11
12
# File 'app/controllers/ecom/core/users_controller.rb', line 10

def active
  render json: User.active
end

#createObject



14
15
16
17
18
19
20
21
# File 'app/controllers/ecom/core/users_controller.rb', line 14

def create
  user = User.new(user_params)
  if user.save
    render json: user, status: :created
  else
    render json: { success: false, errors: user.errors }, status: :unprocessable_entity
  end
end

#indexObject



6
7
8
# File 'app/controllers/ecom/core/users_controller.rb', line 6

def index
  render json: User.all
end

#updateObject



23
24
25
26
27
28
29
# File 'app/controllers/ecom/core/users_controller.rb', line 23

def update
  if @user.update(user_params)
    render json: @user
  else
    render json: { success: false, errors: @user.errors }, status: :unprocessable_entity
  end
end