lib/reform/form/active_model/validations.rb in reform-rails-0.2.1 vs lib/reform/form/active_model/validations.rb in reform-rails-0.2.2

- old
+ new

@@ -141,20 +141,21 @@ messages.to_s end def add(key, error_text) # use rails magic to get the correct error_text and make sure we still update details and fields - text = @amv_errors.add(key, error_text) + error = @amv_errors.add(key, error_text) + error = [error.message] unless error.is_a?(Array) # using error_text instead of text to either keep the symbol which will be # magically replaced with the translate or directly the string - this is also # required otherwise in the custom_errors method we will add the actual message in the # ActiveModel::Errors#details which is not correct if a symbol was passed here Reform::Contract::CustomError.new(key, error_text, @result.to_results) # but since messages method is actually already defined in `Reform::Contract::Result::Errors # we need to update the @dotted_errors instance variable to add or merge a new error - @dotted_errors.key?(key) ? @dotted_errors[key] |= text : @dotted_errors[key] = text + @dotted_errors.key?(key) ? @dotted_errors[key] |= error : @dotted_errors[key] = error instance_variable_set(:@dotted_errors, @dotted_errors) end def method_missing(m, *args, &block) @amv_errors.send(m, *args, &block) # send all methods to the AMV errors, even privates.