Added CSV export for items
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
2026-05-22 04:47:04 +02:00
parent e4bbb329b5
commit ae05cb53b6
5 changed files with 55 additions and 1 deletions

View File

@@ -4,6 +4,19 @@ class ItemsController < ApplicationController
# GET /items or /items.json
def index
@items = Item.all.includes(:category, :user, :room).order(created_at: :desc)
respond_to do |format|
format.html # Rendert ganz normal deine Bestandsliste im Browser
format.csv do
# Dateiname generieren, z.B. "inventar_export_2026-05-22.csv"
filename = "inventar_export_#{Time.current.strftime('%Y-%m-%d')}.csv"
# Daten generieren und als Download an den Browser senden
send_data Item.to_csv,
filename: filename,
type: "text/csv; charset=utf-8; header=present"
end
end
end
# GET /items/1 or /items/1.json