gpt4 book ai didi

ruby-on-rails - Rails 邮箱通知关系

转载 作者:行者123 更新时间:2023-12-02 01:42:27 26 4
gpt4 key购买 nike

我正在尝试建立关系:

has_many :notifications, foreign_key: :notified_object_id, conditions: {notified_object_type: 'AppShare'}, dependent: :destroy

在此页面上找到:http://blog.meldium.com/home/2013/4/22/dont-spam-your-users-batch-notifications-in-rails

我已将其更改为:

has_many :notifications, -> { where( notified_object_type: 'Assigment') }, foreign_key: "notified_object_id", dependent: :destroy

由于 Rails 4 语法,但我得到了这个:

uninitialized constant Assigment::Notification

有人可以帮我吗?

谢谢

最佳答案

对于那些看到类似错误的人,我必须将 class_name: "Mailboxer::Notification" 添加到 has_many 关系中。

has_many :notifications, -> { where( notified_object_type: 'Assignment') },
foreign_key: "notified_object_id", dependent: :destroy,
class_name: "Mailboxer::Notification"

关于ruby-on-rails - Rails 邮箱通知关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27754069/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com