lib/active_data/model/associations/validations.rb in active_data-1.0.0 vs lib/active_data/model/associations/validations.rb in active_data-1.1.0

- old
+ new

@@ -17,45 +17,20 @@ valid_ancestry? || raise_validation_error end private - def run_validations! #:nodoc: - super - emerge_represented_attributes_errors! - errors.empty? - end - def validate_nested! association_names.each do |name| association = association(name) invalid_block = if association.reflection.klass.method_defined?(:invalid_ansestry?) - lambda { |object| object.invalid_ansestry? } + ->(object) { object.invalid_ansestry? } else - lambda { |object| object.invalid? } + ->(object) { object.invalid? } end ActiveData::Model::Validations::NestedValidator .validate_nested(self, name, association.target, &invalid_block) - end - end - - # Move represent attribute errors to the top level: - # - # {:'role.email' => ['Some error']} - # - # to: - # - # {email: ['Some error']} - # - def emerge_represented_attributes_errors! - self.class.represented_attributes.each do |attribute| - key = :"#{attribute.reference}.#{attribute.column}" - messages = errors.messages[key] - if messages.present? - errors[attribute.column].concat(messages) - errors.delete(key) - end end end end end end