3

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

Mads E
  • 163
  • 2
  • 12

2 Answers2

2

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"
mkhatib
  • 5,089
  • 2
  • 26
  • 35
0

Could it just be the typo you've made on 'Assignment'? (You've spelled it 'Assigment', no N.)

Reb
  • 649
  • 1
  • 8
  • 12