Skip to content

Commit

Permalink
Clean up validation of audit_comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdill2 committed Mar 19, 2018
1 parent 02c6e5c commit 0962db4
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/audited/auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def audited(options = {})
self.audit_associated_with = audited_options[:associated_with]

if audited_options[:comment_required]
validate :presence_of_audit_comment
validates_presence_of :audit_comment, unless: :commenting_requirements_met?
before_destroy :require_comment if audited_options[:on].include?(:destroy)
end

Expand Down Expand Up @@ -250,12 +250,6 @@ def write_audit(attrs)
end
end

def presence_of_audit_comment
unless commenting_requirements_met?
errors.add(:audit_comment, "Comment can't be blank!")
end
end

def commenting_requirements_met?
if !auditing_enabled ||
audit_comment.present? ||
Expand Down

0 comments on commit 0962db4

Please sign in to comment.