Make title a notifier attribute
This commit is contained in:
@@ -9,7 +9,8 @@ class Notifier
|
||||
|
||||
def generate
|
||||
recipients.map do |recipient|
|
||||
Notification.create! user: recipient, creator: event.creator, bubble: bubble, resource: resource, body: body
|
||||
Notification.create! user: recipient, creator: event.creator,
|
||||
bubble: bubble, resource: resource, title: title, body: body
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,6 +19,10 @@ class Notifier
|
||||
@event = event
|
||||
end
|
||||
|
||||
def title
|
||||
bubble.title
|
||||
end
|
||||
|
||||
def body
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
class Notifier::Commented < Notifier
|
||||
private
|
||||
def title
|
||||
"RE: " + super
|
||||
end
|
||||
|
||||
def body
|
||||
"#{event.creator.name}"
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-column txt-tight-lines">
|
||||
<strong><%= "RE: " if notification.resource.is_a?(Comment) %><%= notification.bubble.title %></strong>
|
||||
<strong><%= notification.title %></strong>
|
||||
<%= notification.body %> · <%= time_ago_in_words(notification.created_at) %> ago
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,7 @@ class CreateNotifications < ActiveRecord::Migration[8.1]
|
||||
t.references :bubble, null: false, foreign_key: true
|
||||
t.references :resource, null: false, polymorphic: true, index: true
|
||||
t.boolean :read, default: false, null: false
|
||||
t.text :title, null: false
|
||||
t.text :body, null: false
|
||||
|
||||
t.timestamps
|
||||
|
||||
Generated
+1
@@ -183,6 +183,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_01_09_153649) do
|
||||
t.string "resource_type", null: false
|
||||
t.integer "resource_id", null: false
|
||||
t.boolean "read", default: false, null: false
|
||||
t.text "title", null: false
|
||||
t.text "body", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
|
||||
Vendored
+4
-2
@@ -4,7 +4,8 @@ logo_created_kevin:
|
||||
bubble: logo
|
||||
resource: logo (Bubble)
|
||||
read: false
|
||||
body: "created: The logo isn't big enough"
|
||||
title: Logo isn't big enough
|
||||
body: "Added by: David"
|
||||
created_at: <%= 1.week.ago %>
|
||||
|
||||
layout_created_kevin:
|
||||
@@ -13,5 +14,6 @@ layout_created_kevin:
|
||||
bubble: layout
|
||||
resource: layout_overflowing_david (Comment)
|
||||
read: false
|
||||
body: "re: Layout is broken"
|
||||
title: "RE: Layout is broken"
|
||||
body: "David"
|
||||
created_at: <%= 1.week.ago %>
|
||||
|
||||
Reference in New Issue
Block a user