Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails mailboxer notification relation

I'm trying to do the relation:

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 have changed it to:

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

Because of the rails 4 syntax, but i'm getting this:

uninitialized constant Assigment::Notification

can someone help me out here?

Thanks

like image 669
Mads E Avatar asked Apr 21 '26 04:04

Mads E


1 Answers

For those who are seeing similar error, I had to add class_name: "Mailboxer::Notification" to that has_many relation.

has_many :notifications, -> { where( notified_object_type: 'Assignment') },
    foreign_key: "notified_object_id", dependent: :destroy,
    class_name: "Mailboxer::Notification"
like image 125
mkhatib Avatar answered Apr 22 '26 19:04

mkhatib



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!