Add and apply Rails/Pick rubocop rule

The `pick` method was added in Rails 6.0.
This commit is contained in:
Javi Martín
2021-09-19 22:57:06 +02:00
parent 480ab6a9da
commit ea3abd6317
2 changed files with 5 additions and 2 deletions

View File

@@ -288,6 +288,9 @@ Rails/OutputSafety:
Exclude:
- app/helpers/text_with_links_helper.rb
Rails/Pick:
Enabled: true
Rails/PluckId:
Enabled: true

View File

@@ -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)