From 031880c954e6f41036ed10ed4c1637a199a2a329 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 4 Feb 2026 16:17:07 -0600 Subject: [PATCH] fix device page --- lib/towerops_web/live/device_live/show.ex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/towerops_web/live/device_live/show.ex b/lib/towerops_web/live/device_live/show.ex index 09d70055..2fbbb11d 100644 --- a/lib/towerops_web/live/device_live/show.ex +++ b/lib/towerops_web/live/device_live/show.ex @@ -55,10 +55,9 @@ defmodule ToweropsWeb.DeviceLive.Show do |> push_navigate(to: ~p"/devices")} device -> - # Preload site and organization to check access - device = Repo.preload(device, site: :organization) - - if device.site.organization_id == organization.id do + # Check organization access using denormalized organization_id field + # Works for both devices with sites and devices without sites + if device.organization_id == organization.id do maybe_subscribe_and_schedule_refresh(socket, id) tab = Map.get(params, "tab", "overview")