Class: ActsAsTable::RecordError

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

Overview

ActsAsTable record error.

Instance Attribute Summary collapse

Belongs to collapse

Instance Attribute Details

#attribute_nameString

Note:

The attribute name for model-level errors is "base".

Returns the attribute name for this ActsAsTable record error.

Returns:

  • (String)


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
40
41
42
43
44
45
46
47
48
49
# File 'app/models/acts_as_table/record_error.rb', line 14

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

  self.table_name = ActsAsTable.record_errors_table

  # Returns the ActsAsTable record for this error.
  belongs_to :record, **{
    class_name: 'ActsAsTable::Record',
    counter_cache: 'record_errors_count',
    inverse_of: :record_errors,
    required: true,
  }

  # Returns the ActsAsTable value for this error or `nil`.
  #
  # @return [ActsAsTable::Value, nil]
  belongs_to :value, **{
    class_name: 'ActsAsTable::Value',
    counter_cache: 'record_errors_count',
    inverse_of: :record_errors,
    required: false,
  }

  validates :attribute_name, **{
    presence: true,
  }

  validates :message, **{
    presence: true,
    uniqueness: {
      scope: ['record_id', 'attribute_name'],
    },
  }
end

#messageString

Returns the message for this ActsAsTable record error.

Returns:

  • (String)


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
40
41
42
43
44
45
46
47
48
49
# File 'app/models/acts_as_table/record_error.rb', line 14

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

  self.table_name = ActsAsTable.record_errors_table

  # Returns the ActsAsTable record for this error.
  belongs_to :record, **{
    class_name: 'ActsAsTable::Record',
    counter_cache: 'record_errors_count',
    inverse_of: :record_errors,
    required: true,
  }

  # Returns the ActsAsTable value for this error or `nil`.
  #
  # @return [ActsAsTable::Value, nil]
  belongs_to :value, **{
    class_name: 'ActsAsTable::Value',
    counter_cache: 'record_errors_count',
    inverse_of: :record_errors,
    required: false,
  }

  validates :attribute_name, **{
    presence: true,
  }

  validates :message, **{
    presence: true,
    uniqueness: {
      scope: ['record_id', 'attribute_name'],
    },
  }
end

Instance Method Details

#recordActsAsTable::Record

Returns the ActsAsTable record for this error.



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

belongs_to :record, **{
  class_name: 'ActsAsTable::Record',
  counter_cache: 'record_errors_count',
  inverse_of: :record_errors,
  required: true,
}

#valueActsAsTable::Value?

Returns the ActsAsTable value for this error or nil.

Returns:



32
33
34
35
36
37
# File 'app/models/acts_as_table/record_error.rb', line 32

belongs_to :value, **{
  class_name: 'ActsAsTable::Value',
  counter_cache: 'record_errors_count',
  inverse_of: :record_errors,
  required: false,
}