所以我发现了
DEPRECATION WARNING: The following options in your Goal.has_many
:donors declaration are deprecated: :uniq. Please use a scope block
instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name:
'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'
但是我有很多行代码,其中uniq
是唯一的参数,例如:
has_and_belongs_to_many :accounts, uniq: true
我如何将其写成一个块?我已经尝试过has_and_belongs_to_many :accounts, -> { uniq }
,但是我读到在代码行的末尾不能这样写uniq