Rails 4 telah memperkenalkan peringatan penghentian saat menggunakan: uniq => true dengan has_many: through. Sebagai contoh:
has_many :donors, :through => :donations, :uniq => true
Menghasilkan peringatan berikut:
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'
Apa cara yang benar untuk menulis ulang deklarasi has_many di atas?