Sha256: 805589ed8a9807415ea2c85378b8b3eeff9b9a2f1bdef97adcf7050c4e880e35
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
module Ecom module Core class UsersController < ApplicationController before_action :set_user, only: [:update] def index render json: UserSerializer.new(User.all).serializable_hash end def active render json: UserSerializer.new(User.active).serializable_hash end def create user = User.new(user_params) if user.save render json: UserSerializer.new(user).serializable_hash, 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).serializable_hash 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
4 entries across 4 versions & 1 rubygems