class User
scope :active, -> { where(active: true) }
end
运行rubocop时,我收到以下警告:
用括号括起参数
-> { where(active: true) }
,以确保该块与->
方法调用相关联。
我完全不知道我的scope
定义与这个警告有什么关系。你呢?
除了关闭检查因为它目前没有意义之外,我应该如何修复这个警告?
class User
scope :active, -> { where(active: true) }
end
运行rubocop时,我收到以下警告:
用括号括起参数
-> { where(active: true) }
,以确保该块与->
方法调用相关联。
我完全不知道我的scope
定义与这个警告有什么关系。你呢?
除了关闭检查因为它目前没有意义之外,我应该如何修复这个警告?
它希望你这样做:
scope :active, (-> { where(active: true) })
最好关闭警告 :)
这个刺人的lambda语法是完全没问题的。也许你使用的是旧版本的rubocop?
更新: 在0.49.0中已修复。
gem update rubocop
对我很有效。