Class: StoreModel::CombineErrorsStrategies::MergeErrorStrategy
- Inherits:
-
Object
- Object
- StoreModel::CombineErrorsStrategies::MergeErrorStrategy
- Defined in:
- lib/store_model/combine_errors_strategies/merge_error_strategy.rb
Overview
MergeErrorStrategy
copies errors from the StoreModel::Model to the parent record (for Rails < 6.1) or marks the attribute invalid (for Rails >= 6.1).
Instance Method Summary collapse
-
#call(_attribute, base_errors, store_model_errors) ⇒ Object
Merges errors on
attribute
from the child model with parent errors.
Instance Method Details
#call(_attribute, base_errors, store_model_errors) ⇒ Object
Merges errors on attribute
from the child model with parent errors.
attribute
14 15 16 17 18 19 20 21 22 |
# File 'lib/store_model/combine_errors_strategies/merge_error_strategy.rb', line 14 def call(_attribute, base_errors, store_model_errors) if Rails::VERSION::MAJOR < 6 || Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR.zero? base_errors.copy!(store_model_errors) else store_model_errors.errors.each do |error| base_errors.add(:configuration, :invalid, message: error.) end end end |