diff --git a/app/models/concerns/notifiable.rb b/app/models/concerns/notifiable.rb index b10c57f70..aa7d4d3bc 100644 --- a/app/models/concerns/notifiable.rb +++ b/app/models/concerns/notifiable.rb @@ -12,6 +12,10 @@ module Notifiable end end + def notifiable_body + body if attribute_names.include?("body") + end + def notifiable_available? case self.class.name when "ProposalNotification" diff --git a/app/models/notification.rb b/app/models/notification.rb index 738e5ab5f..e5a8e2b95 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -11,8 +11,9 @@ class Notification < ApplicationRecord scope :recent, -> { order(id: :desc) } scope :for_render, -> { includes(:notifiable) } - delegate :notifiable_title, :notifiable_available?, :check_availability, - :linkable_resource, to: :notifiable, allow_nil: true + delegate :notifiable_title, :notifiable_body, :notifiable_available?, + :check_availability, :linkable_resource, + to: :notifiable, allow_nil: true def mark_as_read update(read_at: Time.current) diff --git a/app/views/notifications/_notification.html.erb b/app/views/notifications/_notification.html.erb index cdbad536f..ca14385da 100644 --- a/app/views/notifications/_notification.html.erb +++ b/app/views/notifications/_notification.html.erb @@ -3,7 +3,7 @@ <% locals = { notification: notification, timestamp: notification.timestamp, title: notification.notifiable_title, - body: notification.notifiable.try(:body) } %> + body: notification.notifiable_body } %> <% link_text = render partial: "/notifications/notification_body", locals: locals %> <%= link_to_if notification.link.present?, link_text, notification.link %> <% else %>