Sha256: 5db2c3030efedea50aee7054261f20961fb3cf50f8bc2e1bb2b3f14f7dbe28fb
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
module Ecom module Core class UserRolesController < ApplicationController before_action :set_user_role, only: [:update] def index render json: UserRoleSerializer.new(UserRole.all).serializable_hash end def create user_role = UserRole.new(user_role_params) if user_role.save render json: UserRoleSerializer.new(user_role).serializable_hash, 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: UserRoleSerializer.new(@user_role).serializable_hash 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
4 entries across 4 versions & 1 rubygems