Sha256: 7e12540528565f2185ffabaf6d0a27c3c8208c7f7f00539c8823a3e77b060a2c
Contents?: true
Size: 1011 Bytes
Versions: 7
Compression:
Stored size: 1011 Bytes
Contents
module Ecom module Core class UsersController < ApplicationController before_action :set_user, only: [:update] def index render json: UserSerializer.new(User.all) end def active render json: UserSerializer.new(User.active) end def create user = User.new(user_params) if user.save render json: UserSerializer.new(user), status: :created else render json: { success: false, errors: user.errors }, status: :unprocessable_entity end end def update if @user.update(user_params) render json: UserSerializer.new(@user) else render json: { success: false, errors: @user.errors }, status: :unprocessable_entity end end private def set_user @user = User.find(params[:id]) end def user_params params.require(:user).permit(:first_name, :last_name, :email, :password, :active) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems