Class: InspectableItem
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- InspectableItem
- Defined in:
- app/models/inspectable_item.rb
Class Method Summary collapse
Class Method Details
.get_all ⇒ Object
22 23 24 25 26 |
# File 'app/models/inspectable_item.rb', line 22 def self.get_all items = InspectableItem.all items = ApplicationHelper.key_merge_sort(items, 'id') items end |
.search(_area_id, item_name, item_code) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/models/inspectable_item.rb', line 12 def self.search(_area_id, item_name, item_code) result = InspectableItem result = result.where(inspection_area_id: _area_id) if _area_id != nil && _area_id != "" result = result.where('title ILIKE ?', "%#{item_name}%") if item_name != nil && item_name != "" result = result.where('item_code ILIKE ?', "%#{item_code}%") if item_code != nil && item_code != "" result.class == Class ? all : result end |