Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/acts-as-dag/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Acts
module As
module Dag
VERSION = "4.0.0"
VERSION = "4.1.0"
end
end
end
16 changes: 8 additions & 8 deletions lib/dag/validators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down