Rails 4 hat eine Verwarnungswarnung eingeführt, wenn: uniq => true mit has_many: through verwendet wird. Zum Beispiel:Warnung wegen Verfall bei Verwendung von has_many: through: uniq in Rails 4
has_many :donors, :through => :donations, :uniq => true
ergibt die folgende Warnung:
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'
Was ist der richtige Weg, um die oben has_many Deklaration neu zu schreiben?
Danke, das funktioniert super! Wo hast du das gefunden? Ich konnte es nirgends in der Dokumentation finden. – mysmallidea
Ich sah es tatsächlich in dem Upgrade zu Rails 4 Buch (es ist in Arbeit): http://www.upgradingtorails4.com/ - konnte es nirgendwo anders finden. –
Es ist schwer, eine prägnante Antwort zu finden. Sie, Sir, verdienen mehr Upvotes. – courtsimas