2015-01-03 43 views
3

我想要做的關係:Rails的mailboxer通知關係

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 

由於軌道4語法,但我得到這個:

uniniti alize constant Assigment :: Notification

有人能幫我一下嗎?

謝謝

回答

2

對於那些看到類似錯誤的人,我不得不添加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" 
0

難道這只是你在'Assignment'上犯的錯字嗎? (你拼寫了'Assigment',否N)