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 Enabled: true
Severity: refactor Severity: refactor
Rails/SelectMap:
Enabled: true
Rails/SkipsModelValidations: Rails/SkipsModelValidations:
Enabled: true Enabled: true
ForbiddenMethods: ForbiddenMethods:

View File

@@ -7,7 +7,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
@officers = ::Poll::Officer @officers = ::Poll::Officer
.includes(:user) .includes(:user)
.order("users.username") .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]) .page(params[:page])
.per(50) .per(50)
end end