2015-01-03 6 views
3

내가 관계를 할 노력하고있어이 페이지에서 볼레일 mailboxer 알림 관계

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

: 때문에 레일의

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

: 나는 그것을 변경 http://blog.meldium.com/home/2013/4/22/dont-spam-your-users-batch-notifications-in-rails

4 문법을 사용하지만 다음과 같이 나타납니다.

uniniti alized constant Assigment :: 공지

누군가 나를 도와 줄 수 있습니까?

감사합니다.

답변

2

비슷한 오류가 나타나는 분들을 위해 has_many 관계에 class_name: "Mailboxer::Notification"을 추가해야했습니다.

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

'과제'에서 입력 한 내용이 잘못 되었습니까? (당신은 그것을 'Assigment'이라고 적었습니다.)