From ea3abd6317884253340a45c4ed38f2909a59297f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 19 Sep 2021 22:57:06 +0200 Subject: [PATCH] Add and apply Rails/Pick rubocop rule The `pick` method was added in Rails 6.0. --- .rubocop.yml | 3 +++ app/models/setting.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index baac68548..61ec40311 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -288,6 +288,9 @@ Rails/OutputSafety: Exclude: - app/helpers/text_with_links_helper.rb +Rails/Pick: + Enabled: true + Rails/PluckId: Enabled: true diff --git a/app/models/setting.rb b/app/models/setting.rb index 63e326e09..9fa1e7d68 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -31,7 +31,7 @@ class Setting < ApplicationRecord class << self def [](key) - where(key: key).pluck(:value).first.presence + where(key: key).pick(:value).presence end def []=(key, value) @@ -42,7 +42,7 @@ class Setting < ApplicationRecord def rename_key(from:, to:) if where(key: to).empty? - value = where(key: from).pluck(:value).first.presence + value = where(key: from).pick(:value).presence create!(key: to, value: value) end remove(from)