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.2.11 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.10 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.9 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.7 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.6 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.5 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.4 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.3 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.2 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.1 app/models/ecom/core/equipment_item.rb
ecom_core-1.2.0 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.28 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.27 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.26 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.25 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.24 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.23 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.22 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.21 app/models/ecom/core/equipment_item.rb
ecom_core-1.1.20 app/models/ecom/core/equipment_item.rb