最佳答案
Rails 4在使用: uniq = > true 和 has _ many: through 时引入了一个弃用警告:
has_many :donors, :through => :donations, :uniq => true
产生以下警告:
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'
重写上述 has _ many 声明的正确方法是什么?