Allow notifications with explicit/unexistent links

Notifications usually link to the associated notifiable, but the new
AdminNotifications have a link attribute that may be empty or contain an
external or internal url.
This commit is contained in:
Bertocq
2018-02-28 21:00:45 +01:00
committed by decabeza
parent a683fcff98
commit 4a5235f96f
2 changed files with 16 additions and 2 deletions

View File

@@ -44,7 +44,11 @@ class NotificationsController < ApplicationController
when "Topic"
community_topic_path @notification.linkable_resource.community, @notification.linkable_resource
else
url_for @notification.linkable_resource
if @notification.linkable_resource.is_a?(AdminNotification)
@notification.linkable_resource.link || notifications_path
else
url_for @notification.linkable_resource
end
end
end