From a0409e1cf800213a3a1280b606f2242d3390fa5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=B6hm?= Date: Tue, 26 May 2026 03:15:25 +0200 Subject: [PATCH] Expand items search field for user and room --- app/controllers/categories_controller.rb | 6 +++--- app/controllers/items_controller.rb | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index a319965..4ec4bde 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -15,10 +15,10 @@ class CategoriesController < ApplicationController if params[:query].present? query_str = "%#{params[:query]}%" - @items = @items.where( - "items.name LIKE :q OR items.sku LIKE :q OR items.serial_number LIKE :q OR items.sticker_id LIKE :q", + @items = @items.left_outer_joins(:user).left_outer_joins(:room).where( + "items.name LIKE :q OR items.sku LIKE :q OR items.serial_number LIKE :q OR items.sticker_id LIKE :q OR users.first_name LIKE :q OR users.last_name LIKE :q OR rooms.name LIKE :q", q: query_str - ) + ).order("items.name ASC") end end diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 77bfea8..927d1fa 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -7,11 +7,11 @@ class ItemsController < ApplicationController if params[:query].present? query_str = "%#{params[:query]}%" - # Durchsucht Name, SKU, Seriennummer und deine Sticker-ID gleichzeitig - @items = @items.where( - "items.name LIKE :q OR items.sku LIKE :q OR items.serial_number LIKE :q OR items.sticker_id LIKE :q", + # Durchsucht Name, SKU, Seriennummer und deine Sticker-ID und firstname und lastname gleichzeitig + @items = @items.left_outer_joins(:user).left_outer_joins(:room).where( + "items.name LIKE :q OR items.sku LIKE :q OR items.serial_number LIKE :q OR items.sticker_id LIKE :q OR users.first_name LIKE :q OR users.last_name LIKE :q OR rooms.name LIKE :q", q: query_str - ) + ).order("items.name ASC") end respond_to do |format|