Class: ActiveAgent::Dashboard::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveAgent::Dashboard::ApplicationRecord
- Defined in:
- lib/active_agent/dashboard/app/models/active_agent/dashboard/application_record.rb
Overview
Base class for all Dashboard engine models.
Provides multi-tenant support when configured, allowing the same models to work in both local (single-tenant) and platform (multi-tenant) modes.
Direct Known Subclasses
Agent, AgentRun, AgentTemplate, AgentVersion, RecordingAction, RecordingSnapshot, SandboxRun, SandboxSession, SessionRecording
Class Method Summary collapse
-
.for_owner(owner) ⇒ Object
Scopes records to the current owner (account or user).
-
.owner_association ⇒ Object
Returns the owner association name based on configuration.
-
.table_name ⇒ Object
Override table name calculation to use active_agent_ prefix without the “dashboard_” from the module namespace.
Class Method Details
.for_owner(owner) ⇒ Object
Scopes records to the current owner (account or user). No-op in local mode without owner configuration.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/application_record.rb', line 32 def for_owner(owner) return all if owner.nil? if ActiveAgent::Dashboard.multi_tenant? where(account: owner) elsif column_names.include?("user_id") where(user: owner) else all end end |
.owner_association ⇒ Object
Returns the owner association name based on configuration. In multi-tenant mode, this returns :account. In local mode, this returns :user (optional).
22 23 24 25 26 27 28 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/application_record.rb', line 22 def owner_association if ActiveAgent::Dashboard.multi_tenant? :account else :user end end |
.table_name ⇒ Object
Override table name calculation to use active_agent_ prefix without the “dashboard_” from the module namespace
14 15 16 |
# File 'lib/active_agent/dashboard/app/models/active_agent/dashboard/application_record.rb', line 14 def self.table_name @table_name ||= "active_agent_#{name.demodulize.underscore.pluralize}" end |