Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Don't add to errors manually

Oliver Güntherb26a7bdbfa19
diff --git a/app/models/custom_option.rb b/app/models/custom_option.rb
index ec3bd982a78..157cec14918 100644
--- a/app/models/custom_option.rb
+++ b/app/models/custom_option.rb
@@ -49,7 +49,7 @@ class CustomOption < ApplicationRecord
def assure_at_least_one_option
return if CustomOption.where(custom_field_id: custom_field_id).where.not(id: id).count > 0
- errors[:base] << I18n.t(:'activerecord.errors.models.custom_field.at_least_one_custom_option')
+ errors.add(:base, I18n.t(:'activerecord.errors.models.custom_field.at_least_one_custom_option'))
throw :abort
end
diff --git a/modules/pdf_export/app/models/export_card_configuration.rb b/modules/pdf_export/app/models/export_card_configuration.rb
index fbb734b363c..532587d7892 100644
--- a/modules/pdf_export/app/models/export_card_configuration.rb
+++ b/modules/pdf_export/app/models/export_card_configuration.rb
@@ -69,11 +69,11 @@ class ExportCardConfiguration < ApplicationRecord
def validate(record)
begin
if record.rows.nil? || !(YAML::load(record.rows)).is_a?(Hash)
- record.errors[:rows] << I18n.t('validation_error_yaml_is_badly_formed')
+ record.errors.add(:rows, I18n.t('validation_error_yaml_is_badly_formed'))
return false
end
rescue Psych::SyntaxError => e
- record.errors[:rows] << I18n.t('validation_error_yaml_is_badly_formed')
+ record.errors.add(:rows, I18n.t('validation_error_yaml_is_badly_formed'))
return false
end
@@ -92,7 +92,7 @@ class ExportCardConfiguration < ApplicationRecord
end
end
rescue ArgumentError => e
- record.errors[:rows] << "#{I18n.t('yaml_error')} #{e.message}"
+ record.errors.add(:rows, "#{I18n.t('yaml_error')} #{e.message}")
end
end
end