Rails Mailbox Notification Relationship
I'm trying to fulfill the ratio:
has_many :notifications, foreign_key: :notified_object_id, conditions: {notified_object_type: 'AppShare'}, dependent: :destroy
found on this page: http://blog.meldium.com/home/2013/4/22/dont-spam-your-users-batch-notifications-in-rails
I changed it to:
has_many :notifications, -> { where( notified_object_type: 'Assigment') }, foreign_key: "notified_object_id", dependent: :destroy
Due to the syntax of rails 4, but I get this:
uninitialized constant Assigment :: Notification
Can anyone help me here?
thank
+3
source to share
2 answers
For those seeing a similar error, I had to add class_name: "Mailboxer::Notification"
to this relationship has_many
.
has_many :notifications, -> { where( notified_object_type: 'Assignment') },
foreign_key: "notified_object_id", dependent: :destroy,
class_name: "Mailboxer::Notification"
+2
source to share