Project

General

Profile

Download (1.63 KB) Statistics
| Branch: | Tag: | Revision:

foreman_docker / app / models / docker_container_wizard_states / environment.rb @ bc82d5d5

1
module DockerContainerWizardStates
2
  class Environment < ActiveRecord::Base
3
    self.table_name_prefix = 'docker_container_wizard_states_'
4
    belongs_to :wizard_state, :class_name => DockerContainerWizardState
5
    # Fix me:
6
    # Validations are off on this association as there's a bug in ::Parameter
7
    # that forces validation of reference_id. This will fail on new records as
8
    # validations are executed before parent and children records have been persisted.
9
    has_many :environment_variables, :dependent  => :destroy, :foreign_key => :reference_id,
10
                                     :inverse_of => :environment,
11
                                     :class_name =>
12
                                       'DockerContainerWizardStates::EnvironmentVariable',
13
                                     :validate => false
14
    include ::ParameterValidators
15

    
16
    has_many :exposed_ports,  :dependent  => :destroy, :foreign_key => :reference_id,
17
                              :inverse_of => :environment,
18
                              :class_name => 'DockerContainerWizardStates::ExposedPort',
19
                              :validate => true
20
    has_many :dns,  :dependent  => :destroy, :foreign_key => :reference_id,
21
                    :inverse_of => :environment,
22
                    :class_name => 'DockerContainerWizardStates::Dns',
23
                    :validate => true
24

    
25
    accepts_nested_attributes_for :environment_variables, :allow_destroy => true
26
    accepts_nested_attributes_for :exposed_ports, :allow_destroy => true
27
    accepts_nested_attributes_for :dns, :allow_destroy => true
28

    
29
    def parameters_symbol
30
      :environment_variables
31
    end
32
  end
33
end