From 8a515974085c85fdcfb2635eb6a6ef4382ad0981 Mon Sep 17 00:00:00 2001 From: Kevin McConnell Date: Fri, 10 Jan 2025 10:23:40 +0000 Subject: [PATCH] Add direct linking to comments --- app/models/bubble.rb | 4 +--- app/models/comment.rb | 2 +- app/models/concerns/notifiable.rb | 7 +++++++ config/routes.rb | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 app/models/concerns/notifiable.rb diff --git a/app/models/bubble.rb b/app/models/bubble.rb index 1e617189d..67316354a 100644 --- a/app/models/bubble.rb +++ b/app/models/bubble.rb @@ -1,11 +1,9 @@ class Bubble < ApplicationRecord - include Assignable, Boostable, Colored, Commentable, Eventable, Messages, Poppable, Searchable, Staged, Taggable + include Assignable, Boostable, Colored, Commentable, Eventable, Messages, Notifiable, Poppable, Searchable, Staged, Taggable belongs_to :bucket, touch: true belongs_to :creator, class_name: "User", default: -> { Current.user } - has_many :notifications, as: :resource, dependent: :destroy - has_one_attached :image, dependent: :purge_later before_save :set_default_title diff --git a/app/models/comment.rb b/app/models/comment.rb index 3de28081f..b4fd7d0c5 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,5 @@ class Comment < ApplicationRecord - include Searchable, Messageable + include Messageable, Notifiable, Searchable belongs_to :creator, class_name: "User", default: -> { Current.user } diff --git a/app/models/concerns/notifiable.rb b/app/models/concerns/notifiable.rb new file mode 100644 index 000000000..8cfc7b112 --- /dev/null +++ b/app/models/concerns/notifiable.rb @@ -0,0 +1,7 @@ +module Notifiable + extend ActiveSupport::Concern + + included do + has_many :notifications, as: :resource, dependent: :destroy + end +end diff --git a/config/routes.rb b/config/routes.rb index d0f860f96..6b5153088 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,10 @@ Rails.application.routes.draw do route_for :bucket_bubble, bubble.bucket, bubble, options end + resolve "Comment" do |comment, options| + route_for :bucket_bubble, comment.bubble.bucket, comment.bubble, anchor: ActionView::RecordIdentifier.dom_id(comment) + end + resources :bubbles resources :notifications