module Ecom module Core class EquipmentItem < ApplicationRecord READY = 'Ready' UNDER_MAINTENANCE = 'Under Maintenance' belongs_to :equipment belongs_to :current_location, class_name: 'Ecom::Core::EquipmentLocation' validates :name, :status, :serial_number, :purchase_date, :purchase_price, presence: true validates :serial_number, uniqueness: true def self.search(param) search_term = "%#{param.downcase}%" Ecom::Core::EquipmentItem .joins(:equipment) .where( 'lower(ecom_core_equipment_items.name) LIKE ? OR lower(ecom_core_equipment.name) LIKE ?', search_term, search_term ) end end end end