Add and apply Rails/SelectMap rule

This rule was introduced in rubocop-rails 2.21.0. Using `pluck` is
easier to read.
This commit is contained in:
Javi Martín
2023-10-03 19:36:40 +02:00
parent 21d39bac62
commit 522eb6cfa3
2 changed files with 4 additions and 1 deletions

View File

@@ -460,6 +460,9 @@ Rails/SaveBang:
Enabled: true
Severity: refactor
Rails/SelectMap:
Enabled: true
Rails/SkipsModelValidations:
Enabled: true
ForbiddenMethods:

View File

@@ -7,7 +7,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
@officers = ::Poll::Officer
.includes(:user)
.order("users.username")
.where(id: @poll.officer_assignments.select(:officer_id).distinct.map(&:officer_id))
.where(id: @poll.officer_assignments.distinct.pluck(:officer_id))
.page(params[:page])
.per(50)
end