Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: collect errors from record without exception #2610

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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