diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index c44b721..fe59ab9 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -9,6 +9,6 @@ def index def update notification = Notification.find(params[:id]) notification.clicked! - redirect_to NotificationDecorator.new(notification).redirect_path + redirect_to NotificationDecorator.new(notification).redirect_after_click end end diff --git a/app/models/notification_decorator.rb b/app/models/notification_decorator.rb index ad86f0a..da41f11 100644 --- a/app/models/notification_decorator.rb +++ b/app/models/notification_decorator.rb @@ -1,14 +1,14 @@ class NotificationDecorator < SimpleDelegator - def redirect_path + def redirect_after_click case notifiable when Comment notifiable.post when Connection notifiable.follower - when Post, Invitation - notifiable - else + when Like notifiable.likeable.is_a?(Comment) ? notifiable.likeable.post : notifiable.likeable + else + notifiable end end end