Sha256: 7c459138e2b0e31c75c1a0c85226661e1b10e6b897592dcb93b9e0a176e23cf8

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

module Ecom
  module Core
    class ApplicationModulesController < ApplicationController
      def index
        render json: ApplicationModuleSerializer.new(ApplicationModule.all).serializable_hash
      end

      def create
        application_module = ApplicationModule.new(application_module_params)
        if application_module.save
          render json: ApplicationModuleSerializer.new(application_module).serializable_hash, status: :created
        else
          render json: { success: false, errors: application_module.errors }, status: :unprocessable_entity
        end
      end

      def update
        application_module = ApplicationModule.find(params[:id])
        if application_module.update(application_module_params)
          render json: ApplicationModuleSerializer.new(application_module).serializable_hash
        else
          render json: { success: false, errors: application_module.errors }, status: :unprocessable_entity
        end
      end

      private

      def application_module_params
        params.require(:application_module).permit(:code, :name)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecom_core-1.1.6 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.1.5 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.1.4 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.1.3 app/controllers/ecom/core/application_modules_controller.rb