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")