Sha256: f784ae74274473764495d45b012102ca129f958c363d5f6e03945a6fe8180b1f
Contents?: true
Size: 906 Bytes
Versions: 16
Compression:
Stored size: 906 Bytes
Contents
module Ecom module Core class UnitCostsController < ApplicationController before_action :set_service, only: %i[update] def index unit_costs = UnitCost.where(active: true) serialized = ActiveModelSerializers::SerializableResource.new(unit_costs) render json: { success: true, data: serialized } end def create unit_cost = UnitCost.new(unit_cost_params) if unit_cost.save render json: unit_cost, status: :created else render json: { success: false, errors: unit_cost.errors }, status: :unprocessable_entity end end private def unit_cost_params params.require(:unit_cost).permit(:resource_type_id, :quantity, :measurement_unit_id, :price, :currency_id, :utilization_factor, :effective_date, :set_by_id) end end end end
Version data entries
16 entries across 16 versions & 1 rubygems