module Logistics module Core class BroadGaugeBb < ApplicationRecord validates :length, :width, :height, :actual_weight, presence: true, allow_blank: false validates :break_bulk_unit_id, uniqueness: {scope: [:break_bulk_unit_id, :length, :width, :height, :actual_weight]} belongs_to :break_bulk_unit def self.fetch_all result = [] broad_gauges = BroadGaugeBb.all broad_gauges.each do |broad_gauge| result.push({id: broad_gauge.id, break_bulk_unit_id: broad_gauge.break_bulk_unit_id, break_bulk_unit_name: broad_gauge.break_bulk_unit.name, length: broad_gauge.length, width: broad_gauge.width, height: broad_gauge.height, actual_weight: broad_gauge.actual_weight}) end return result end end end end