Sha256: d934bea98e73764c69d2359a6f9b9b2799785593914ee71c5ad801209ef6725c

Contents?: true

Size: 739 Bytes

Versions: 40

Compression:

Stored size: 739 Bytes

Contents

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

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ecom_core-1.1.19 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.18 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.17 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.16 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.15 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.14 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.13 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.12 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.11 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.10 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.9 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.8 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.7 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.6 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.5 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.4 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.3 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.2 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.1 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.0 app/models/ecom/core/equipment_item.rb