diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-10-14 20:53:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 20:53:11 +0200 |
commit | 9b978872cc1a86c7d82afda4060c909dc7ca2536 (patch) | |
tree | 36a210c24d261c278ddf8ada34b817f161a35942 /app/models/admin | |
parent | 032d9bcaeda5cf2bf39f959bd6ba21bdc1c48f0c (diff) |
Fix 404 error when filtering admin action logs by non-existent target account (#16643)
Currently, there is no way for an admin to delete an account record. However, should that happen in the future, or should an admin mistype an account id, `/admin/action_logs?target_account_id=<non-existent-account-id>` currently returns a 404 instead of an empty list. With this commit, the aforementioned page returns a correct list instead (potentially non-empty if the account has been manually deleted)
Diffstat (limited to 'app/models/admin')
-rw-r--r-- | app/models/admin/action_log_filter.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/admin/action_log_filter.rb b/app/models/admin/action_log_filter.rb index a1c156a8b..6e19dcf70 100644 --- a/app/models/admin/action_log_filter.rb +++ b/app/models/admin/action_log_filter.rb @@ -76,7 +76,7 @@ class Admin::ActionLogFilter when 'account_id' Admin::ActionLog.where(account_id: value) when 'target_account_id' - account = Account.find(value) + account = Account.find_or_initialize_by(id: value) Admin::ActionLog.where(target: [account, account.user].compact) else raise "Unknown filter: #{key}" |