Class: Tasker::ApplicationRecord
- Inherits:
- 
      ActiveRecord::Base
      
        - Object
- ActiveRecord::Base
- Tasker::ApplicationRecord
 
- Defined in:
- app/models/tasker/application_record.rb
Overview
Abstract base class for all Tasker models that provides optional secondary database support.
This class follows Rails multi-database conventions using the connects_to API.
When secondary database is enabled, it connects to a database named 'tasker' in database.yml.
Direct Known Subclasses
AnnotationType, DependentSystem, DependentSystemObjectMap, NamedStep, NamedTask, NamedTasksNamedStep, StepDagRelationship, Task, TaskAnnotation, TaskNamespace, TaskTransition, WorkflowStep, WorkflowStepEdge, WorkflowStepTransition
Class Method Summary collapse
- 
  
    
      .configure_database_connections  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Configure database connections based on Tasker configuration This follows Rails multi-database conventions but only when database is actually available. 
- 
  
    
      .database_configuration_exists?(db_name)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Check if a database configuration exists in the current environment. 
Class Method Details
.configure_database_connections ⇒ Object
Configure database connections based on Tasker configuration This follows Rails multi-database conventions but only when database is actually available
| 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # File 'app/models/tasker/application_record.rb', line 36 def self.configure_database_connections # Ensure Tasker configuration is available - fail fast if not unless defined?(::Tasker::Configuration.configuration) = 'Tasker::Configuration.configuration is not available. This indicates a Rails initialization order issue. ' \ 'Ensure Tasker is properly initialized before models are loaded.' raise StandardError, end config = ::Tasker::Configuration.configuration.database if config.enable_secondary_database && config.name.present? # Check if the database configuration actually exists before calling connects_to if database_configuration_exists?(config.name) # Use connects_to for proper Rails multi-database support connects_to database: { writing: config.name.to_sym, reading: config.name.to_sym } else = "Tasker secondary database '#{config.name}' is enabled but not found in database.yml. " \ 'Using default database.' Rails.logger.warn end end rescue ActiveRecord::DatabaseConfigurations::InvalidConfigurationError => e # Log database configuration errors but don't fail startup - this allows for # environments where the secondary database might not be available Rails.logger.warn "Tasker database configuration error: #{e.message}" end | 
.database_configuration_exists?(db_name) ⇒ Boolean
Check if a database configuration exists in the current environment
| 63 64 65 | # File 'app/models/tasker/application_record.rb', line 63 def self.database_configuration_exists?(db_name) Rails.application.config.database_configuration.key?(db_name.to_s) end |