Add and apply Rails/Pick rubocop rule
The `pick` method was added in Rails 6.0.
This commit is contained in:
@@ -288,6 +288,9 @@ Rails/OutputSafety:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- app/helpers/text_with_links_helper.rb
|
- app/helpers/text_with_links_helper.rb
|
||||||
|
|
||||||
|
Rails/Pick:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Rails/PluckId:
|
Rails/PluckId:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Setting < ApplicationRecord
|
|||||||
|
|
||||||
class << self
|
class << self
|
||||||
def [](key)
|
def [](key)
|
||||||
where(key: key).pluck(:value).first.presence
|
where(key: key).pick(:value).presence
|
||||||
end
|
end
|
||||||
|
|
||||||
def []=(key, value)
|
def []=(key, value)
|
||||||
@@ -42,7 +42,7 @@ class Setting < ApplicationRecord
|
|||||||
|
|
||||||
def rename_key(from:, to:)
|
def rename_key(from:, to:)
|
||||||
if where(key: to).empty?
|
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)
|
create!(key: to, value: value)
|
||||||
end
|
end
|
||||||
remove(from)
|
remove(from)
|
||||||
|
|||||||
Reference in New Issue
Block a user