Rails 邮箱通知关系

Rails mailboxer notification relation

我正在尝试建立关系:

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

有人可以帮我吗?

谢谢

会不会是你在 'Assignment' 上打错了字? (您已经拼写 'Assigment',没有 N。)

对于那些看到类似错误的人,我必须将 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"