Class: ActsAsTable::HasManyTarget

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/acts_as_table/has_many_target.rb

Overview

ActsAsTable collection macro association target.

Instance Attribute Summary collapse

Belongs to collapse

Instance Attribute Details

#positionInteger

Returns the position of this ActsAsTable collection macro association target.

Returns:

  • (Integer)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/acts_as_table/has_many_target.rb', line 8

class HasManyTarget < ::ActiveRecord::Base
  # @!parse
  #   include ActsAsTable::ValueProvider
  #   include ActsAsTable::ValueProviderAssociationMethods

  self.table_name = ActsAsTable.has_many_targets_table

  # Returns the ActsAsTable collection macro association for this target.
  belongs_to :has_many, **{
    class_name: 'ActsAsTable::HasMany',
    inverse_of: :has_many_targets,
    required: true,
  }

  # Returns the ActsAsTable record model for this ActsAsTable collection macro association target.
  belongs_to :record_model, **{
    class_name: 'ActsAsTable::RecordModel',
    inverse_of: :has_many_targets,
    required: true,
  }

  validates :position, **{
    numericality: {
      greater_than_or_equal_to: 1,
      only_integer: true,
    },
    presence: true,
    uniqueness: {
      scope: ['has_many_id'],
    },
  }
end

Instance Method Details

#has_manyActsAsTable::HasMany

Returns the ActsAsTable collection macro association for this target.



16
17
18
19
20
# File 'app/models/acts_as_table/has_many_target.rb', line 16

belongs_to :has_many, **{
  class_name: 'ActsAsTable::HasMany',
  inverse_of: :has_many_targets,
  required: true,
}

#record_modelActsAsTable::RecordModel

Returns the ActsAsTable record model for this ActsAsTable collection macro association target.



23
24
25
26
27
# File 'app/models/acts_as_table/has_many_target.rb', line 23

belongs_to :record_model, **{
  class_name: 'ActsAsTable::RecordModel',
  inverse_of: :has_many_targets,
  required: true,
}