Sha256: b5255df6cdf7b40eacf0806973eeb0e4db0bf2f0fc4c86294ca1758f95ae48cf
Contents?: true
Size: 605 Bytes
Versions: 17
Compression:
Stored size: 605 Bytes
Contents
module Ecom module Core class MaterialItem < ApplicationRecord before_save :assign_serial_number belongs_to :material_identity validates :serial_number, presence: true, uniqueness: true validates :material_identity_id, :material_identity, presence: true validates :serial_number, format: { with: /^SN_\d+$/, message: 'Invalid serial number format', multiline: true } validates :price, numericality: { greater_than: 0 }, allow_nil: true def assign_serial_number self.serial_number = "SN_#{(Time.now.to_f * 1000).to_i}" end end end end
Version data entries
17 entries across 17 versions & 1 rubygems