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