module Ecom module Core class Equipment < ApplicationRecord belongs_to :equipment_category validates :name, :minimum_acquisition_time, presence: true validates :name, uniqueness: { scope: :equipment_category_id } def self.search(param) search_term = "%#{param.downcase}%" Ecom::Core::Equipment .joins(:equipment_category) .where( 'lower(ecom_core_equipment.name) LIKE ? OR lower(ecom_core_equipment_categories.name) LIKE ?', search_term, search_term ) end end end end