mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 09:13:05 +08:00
Implement dynamic subject class handling in generalnotification [SCI-9825]
This commit is contained in:
parent
41c5ecf1d8
commit
0f12be6a26
2 changed files with 7 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue