simukappu/activity_notification

No way to customize printable_name when triggering notify ?

funkypierre opened this issue · 2 comments

Hello there !

I wish to be able to customize the printable_name when I trigger the notify call.
But it seems that we're only able to define it once when declaring 'acts_as_notifiable'.
I want my model to have multiple notify cases, not just related to one attribute or relation. Is there a way to do it ?

Thanks :)

Uhm, thank you for your feedback.
Notification record stored in DB does not have printable_name as its column. printable_name is configured in Notifiable model. That's why you can define this once when declaring 'acts_as_notifiable', but cannot customize it when you trigger the notify call.
As workaround, you can set your printable notifiable name in parameters like this:

@comment.notify :users, parameters: { printable_notifiable_name: "your printable name" }, send_later: false

and customize your notification view like this:

<%#= notification.notifiable.printable_notifiable_name(notification.target) %>
<%= notification.parameters["printable_notifiable_name"] %>

Do you have any comments?

Okay then, thank you !