我收到弃用警告:
弃用警告:不推荐使用 Contact.belongs_to 中的以下选项:customer 声明::conditions。请改用范围块。例如,以下内容:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
应改写如下:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'
这是带有 :condition 的行
belongs_to :customer, foreign_key: 'contactable_id',\
conditions: "contacts.contactable_type = 'Customer'"
我只是尝试了一些变体,但无法修复。也许我错过了什么
这应该有效:
belongs_to :customer, -> { where(contactable_type: 'Customer') },
foreign_key: 'contactable_id'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句