Project

General

Profile

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

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

1 6d101d7a Dmitri Dolguikh
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 ac230210 David Davis
                                     :inverse_of => :environment,
11
                                     :class_name =>
12
                                       'DockerContainerWizardStates::EnvironmentVariable',
13
                                     :validate => false
14 6d101d7a Dmitri Dolguikh
    include ::ParameterValidators
15
16 8e2848d5 Vanya Jauhal
    has_many :exposed_ports,  :dependent  => :destroy, :foreign_key => :reference_id,
17
                              :inverse_of => :environment,
18
                              :class_name => 'DockerContainerWizardStates::ExposedPort',
19
                              :validate => true
20 bc82d5d5 Vanya Jauhal
    has_many :dns,  :dependent  => :destroy, :foreign_key => :reference_id,
21
                    :inverse_of => :environment,
22
                    :class_name => 'DockerContainerWizardStates::Dns',
23
                    :validate => true
24 8e2848d5 Vanya Jauhal
25 6d101d7a Dmitri Dolguikh
    accepts_nested_attributes_for :environment_variables, :allow_destroy => true
26 8e2848d5 Vanya Jauhal
    accepts_nested_attributes_for :exposed_ports, :allow_destroy => true
27 bc82d5d5 Vanya Jauhal
    accepts_nested_attributes_for :dns, :allow_destroy => true
28 6d101d7a Dmitri Dolguikh
29
    def parameters_symbol
30
      :environment_variables
31
    end
32
  end
33
end