diff --git a/README.rdoc b/README.rdoc index 76876a6..332ee86 100644 --- a/README.rdoc +++ b/README.rdoc @@ -14,6 +14,10 @@ Version 2.5.3 is based on Rails 3.0.0 and uses all of the new ActiveModel/Active Version 3.0.0 is based on Rails 3.2.12 and tested against Ruby 1.9.3-p385. 3.0.0 fixes issues with the ActiveRecord method connected? being overwritten by acts-as-dag. Thanks to Ryan Glover (@ersatzryan) for the patch. +Version 4.0.0 is based and tested on Rails 5.2 to 6.1, ruby 2.6 and 2.7 + +Version 4.1.0 adds support for Rails 7 + === What's a DAG? http://en.wikipedia.org/wiki/Directed_acyclic_graph diff --git a/lib/acts-as-dag/version.rb b/lib/acts-as-dag/version.rb index c2f20ad..6d7efb4 100644 --- a/lib/acts-as-dag/version.rb +++ b/lib/acts-as-dag/version.rb @@ -1,7 +1,7 @@ module Acts module As module Dag - VERSION = "4.0.0" + VERSION = "4.1.0" end end end diff --git a/lib/dag/validators.rb b/lib/dag/validators.rb index 2b55b4e..3ad5ecb 100644 --- a/lib/dag/validators.rb +++ b/lib/dag/validators.rb @@ -4,12 +4,12 @@ module Dag class CreateCorrectnessValidator < ActiveModel::Validator def validate(record) - record.errors[:base] << 'Link already exists between these points' if has_duplicates(record) - record.errors[:base] << 'Link already exists in the opposite direction' if has_long_cycles(record) - record.errors[:base] << 'Link must start and end in different places' if has_short_cycles(record) + record.errors.add(:base, 'Link already exists between these points') if has_duplicates(record) + record.errors.add(:base, 'Link already exists in the opposite direction') if has_long_cycles(record) + record.errors.add(:base, 'Link must start and end in different places') if has_short_cycles(record) cnt = check_possible(record) - record.errors[:base] << 'Cannot create a direct link with a count other than 0' if cnt == 1 - record.errors[:base] << 'Cannot create an indirect link with a count less than 1' if cnt == 2 + record.errors.add(:base, 'Cannot create a direct link with a count other than 0') if cnt == 1 + record.errors.add(:base, 'Cannot create an indirect link with a count less than 1') if cnt == 2 end private @@ -39,9 +39,9 @@ def check_possible(record) class UpdateCorrectnessValidator < ActiveModel::Validator def validate(record) - record.errors[:base] << "No changes" unless record.changed? - record.errors[:base] << "Do not manually change the count value" if manual_change(record) - record.errors[:base] << "Cannot make a direct link with count 1 indirect" if direct_indirect(record) + record.errors.add(:base, "No changes") unless record.changed? + record.errors.add(:base, "Do not manually change the count value") if manual_change(record) + record.errors.add(:base, "Cannot make a direct link with count 1 indirect") if direct_indirect(record) end private