1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/app/views/api/notifications/index.json.jbuilder

14 lines
852 B
Plaintext
Raw Normal View History

2015-05-05 03:10:25 +02:00
json.array!(@notifications) do |notification|
2016-03-23 18:39:41 +01:00
if Module.const_get(notification.attached_object_type) and notification.attached_object # WHY WERE WE DOING Object.const_defined?(notification.attached_object_type) ??? Why not just deleting obsolete notifications ?! Object.const_defined? was introducing a bug! Module.const_get is a TEMPORARY fix, NOT a solution
2015-05-05 03:10:25 +02:00
json.extract! notification, :id, :notification_type_id, :notification_type, :created_at, :is_read
json.attached_object notification.attached_object
json.message do
2016-03-23 18:39:41 +01:00
if notification.notification_type.nil?
json.partial! 'api/notifications/undefined_notification', notification: notification
else
json.partial! "/api/notifications/#{notification.notification_type}", notification: notification
end
2015-05-05 03:10:25 +02:00
end
end
end.delete_if {|n| n['id'] == nil }