Sha256: dcfbaf0723ba4c43e47a3bf9595747ed0fd44233351739b4af4785dd44cfd2cd

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

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

      def create
        application_module = ApplicationModule.new(application_module_params)
        if application_module.save
          render json: ApplicationModuleSerializer.new(application_module), 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)
        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

7 entries across 7 versions & 1 rubygems

Version Path
ecom_core-1.1.2 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.1.1 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.1.0 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.0.25 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.0.24 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.0.23 app/controllers/ecom/core/application_modules_controller.rb
ecom_core-1.0.22 app/controllers/ecom/core/application_modules_controller.rb