diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 22eb85297..e84f9a003 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -106,7 +106,9 @@ module ApplicationHelper { type: :smart_annotation_added, title: sanitize_input(title), - subject: subject, + subject_id: subject.id, + subject_class: subject.class.name, + subject_name: subject.respond_to?(:name) && subject.name, user: target_user } ) diff --git a/app/notifications/general_notification.rb b/app/notifications/general_notification.rb index 67674175b..f74c2a298 100644 --- a/app/notifications/general_notification.rb +++ b/app/notifications/general_notification.rb @@ -14,6 +14,9 @@ class GeneralNotification < BaseNotification end def subject - params[:subject] + subject_class = params[:subject_class].constantize + subject_class.find(params[:subject_id]) + rescue NameError, ActiveRecord::RecordNotFound + NonExistantRecord.new(params[:subject_name]) end end