Skip to content

Commit 8dc5609

Browse files
authored
fix: collect errors from record without exception (#2610)
* fix: collect errors from record without exception * .
1 parent 5733e8e commit 8dc5609

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

app/controllers/avo/base_controller.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,14 @@ def perform_action_and_record_errors(&block)
245245
end
246246

247247
# Add the errors from the record
248-
@errors = @record.errors.full_messages.reject { |error| exception_message.include? error }.unshift exception_message
248+
@errors = @record.errors.full_messages
249249

250-
succeeded
250+
# Remove duplicated errors
251+
if exception_message.present?
252+
@errors = @errors.reject { |error| exception_message.include? error }.unshift exception_message
253+
end
254+
255+
@errors.any? ? false : succeeded
251256
end
252257

253258
def model_params

spec/system/model_errors_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
around do |example|
77
Comment.before_destroy do
88
errors.add(:base, "Some Errors")
9-
10-
throw(:abort)
119
end
1210

1311
example.run

0 commit comments

Comments
 (0)