Added Search function for items and fixed javascript controller
This commit is contained in:
@@ -9,7 +9,17 @@ class CategoriesController < ApplicationController
|
||||
# GET /categories/1 or /categories/1.json
|
||||
def show
|
||||
@category = Category.find(params[:id])
|
||||
@items = @category.items.includes(:user, :room).order(:name)
|
||||
|
||||
# Basis-Abfrage: Alle Items dieser Kategorie laden
|
||||
@items = @category.items.includes(:user, :room).order(created_at: :desc)
|
||||
|
||||
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",
|
||||
q: query_str
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# GET /categories/new
|
||||
|
||||
Reference in New Issue
Block a user