Class: ActsAsTable::RecordError
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActsAsTable::RecordError
- Defined in:
- app/models/acts_as_table/record_error.rb
Overview
ActsAsTable record error.
Instance Attribute Summary collapse
-
#attribute_name ⇒ String
Returns the attribute name for this ActsAsTable record error.
-
#message ⇒ String
Returns the message for this ActsAsTable record error.
Belongs to collapse
-
#record ⇒ ActsAsTable::Record
Returns the ActsAsTable record for this error.
-
#value ⇒ ActsAsTable::Value?
Returns the ActsAsTable value for this error or
nil
.
Instance Attribute Details
#attribute_name ⇒ String
Note:
The attribute name for model-level errors is "base".
Returns the attribute name for this ActsAsTable record error.
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 |
#message ⇒ String
Returns the message for this ActsAsTable record error.
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
#record ⇒ ActsAsTable::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, } |
#value ⇒ ActsAsTable::Value?
Returns the ActsAsTable value for this error or nil
.
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, } |