Class: Ecom::Core::UsersController
Instance Method Summary
collapse
#current_user, #logged_in?
Instance Method Details
#active ⇒ Object
15
16
17
|
# File 'app/controllers/ecom/core/users_controller.rb', line 15
def active
render json: User.active
end
|
#create ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/controllers/ecom/core/users_controller.rb', line 19
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
|
#index ⇒ Object
6
7
8
|
# File 'app/controllers/ecom/core/users_controller.rb', line 6
def index
render json: User.all
end
|
#lookup ⇒ Object
10
11
12
13
|
# File 'app/controllers/ecom/core/users_controller.rb', line 10
def lookup
data = ActiveModelSerializers::SerializableResource.new(User.all, each_serializer: UserLookupSerializer)
render json: { success: true, data: data }
end
|
#update ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/controllers/ecom/core/users_controller.rb', line 28
def update
if @user.update(user_params)
render json: @user
else
render json: { success: false, errors: @user.errors }, status: :unprocessable_entity
end
end
|