将参数括起来以确保该块将与方法调用相关联
Parenthesize the param to make sure that block will be associated with method call
class User
scope :active, -> { where(active: true) }
end
运行 rubocop 我收到以下警告:
Parenthesize the param -> { where(active: true) }
to make sure that
the block will be associated with the ->
method call.
我完全不知道我的 scope
定义与此警告有什么关系。你呢?
除了关闭检查之外,我该如何修复警告,因为它目前没有意义?
它要你这样做:
scope :active, (-> { where(active: true) })
最好关闭警告:)
这种 stabby lambda 语法非常好。也许你有旧的 rubocop 版本?
更新: 已在 0.49.0 中修复。
gem update rubocop
对我有用。
class User
scope :active, -> { where(active: true) }
end
运行 rubocop 我收到以下警告:
Parenthesize the param
-> { where(active: true) }
to make sure that the block will be associated with the->
method call.
我完全不知道我的 scope
定义与此警告有什么关系。你呢?
除了关闭检查之外,我该如何修复警告,因为它目前没有意义?
它要你这样做:
scope :active, (-> { where(active: true) })
最好关闭警告:)
这种 stabby lambda 语法非常好。也许你有旧的 rubocop 版本?
更新: 已在 0.49.0 中修复。
gem update rubocop
对我有用。