Sha256: 8ab6e14ff3bd826cca37193cb6875a8782af3542acd471a432153094a1e6b2f7
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module Ecom module Core class EquipmentItem < ApplicationRecord # Equipment Statuses READY = 'Ready'.freeze UNDER_MAINTENANCE = 'Under Maintenance'.freeze EQUIPMENT_STATUSES = [READY, UNDER_MAINTENANCE].freeze # Duty Statuses AVAILABLE = 'Available'.freeze BOOKED = 'Booked'.freeze ON_DUTY = 'On Duty'.freeze DUTY_STATUSES = [AVAILABLE, BOOKED, ON_DUTY].freeze belongs_to :equipment belongs_to :country belongs_to :current_location, class_name: 'Ecom::Core::EquipmentLocation' validates :name, :status, :serial_number, :purchase_date, :purchase_price, presence: true validates :status, inclusion: EQUIPMENT_STATUSES validates :duty_status, inclusion: DUTY_STATUSES 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecom_core-1.2.12 | app/models/ecom/core/equipment_item.rb |