Sha256: a5ead7d9281a2a78ba164d0788bb4b458bee2247fdeb33119d1897f25cb7ccdd

Contents?: true

Size: 935 Bytes

Versions: 34

Compression:

Stored size: 935 Bytes

Contents

module Ecom
  module Core
    class UserRolesController < ApplicationController
      before_action :set_user_role, only: [:update]

      def index
        render json: UserRole.all
      end

      def create
        user_role = UserRole.new(user_role_params)

        if user_role.save
          render json: user_role, status: :created
        else
          render json: { success: false, errors: user_role.errors }, status: :unprocessable_entity
        end
      end

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


      private

      def set_user_role
        @user_role = UserRole.find(params[:id])
      end

      def user_role_params
        params.require(:user_role).permit(:name, :application_module_id)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
ecom_core-1.1.20 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.19 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.18 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.17 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.16 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.15 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.14 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.13 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.12 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.11 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.10 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.9 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.8 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.7 app/controllers/ecom/core/user_roles_controller.rb