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.2.12 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.11 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.10 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.9 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.7 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.6 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.5 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.4 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.3 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.2 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.1 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.2.0 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.28 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.27 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.26 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.25 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.24 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.23 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.22 app/controllers/ecom/core/user_roles_controller.rb
ecom_core-1.1.21 app/controllers/ecom/core/user_roles_controller.rb