Sha256: 4fbffb91dde9b19ab80aefb2cfdcd82fdaa86e39fc0324d1d75a3763e76db135

Contents?: true

Size: 931 Bytes

Versions: 34

Compression:

Stored size: 931 Bytes

Contents

module Ecom
  module Core
    class UsersController < ApplicationController
      before_action :set_user, only: [:update]

      def index
        render json: User.all
      end

      def active
        render json: User.active
      end

      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

      def update
        if @user.update(user_params)
          render json: @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

34 entries across 34 versions & 1 rubygems

Version Path
ecom_core-1.2.12 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.11 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.10 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.9 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.7 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.6 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.5 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.4 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.3 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.2 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.1 app/controllers/ecom/core/users_controller.rb
ecom_core-1.2.0 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.28 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.27 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.26 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.25 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.24 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.23 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.22 app/controllers/ecom/core/users_controller.rb
ecom_core-1.1.21 app/controllers/ecom/core/users_controller.rb