Skip to content

Commit

Permalink
fix: collect errors from record without exception (#2610)
Browse files Browse the repository at this point in the history
* fix: collect errors from record without exception

* .
  • Loading branch information
Paul-Bob committed Mar 25, 2024
1 parent 5733e8e commit 8dc5609
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 7 additions & 2 deletions app/controllers/avo/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,14 @@ def perform_action_and_record_errors(&block)
end

# Add the errors from the record
@errors = @record.errors.full_messages.reject { |error| exception_message.include? error }.unshift exception_message
@errors = @record.errors.full_messages

succeeded
# Remove duplicated errors
if exception_message.present?
@errors = @errors.reject { |error| exception_message.include? error }.unshift exception_message
end

@errors.any? ? false : succeeded
end

def model_params
Expand Down
2 changes: 0 additions & 2 deletions spec/system/model_errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
around do |example|
Comment.before_destroy do
errors.add(:base, "Some Errors")

throw(:abort)
end

example.run
Expand Down

0 comments on commit 8dc5609

Please sign in to comment.