diff --git a/app/models/bubble/watchable.rb b/app/models/bubble/watchable.rb index 05e5f9dbd..eff70c96f 100644 --- a/app/models/bubble/watchable.rb +++ b/app/models/bubble/watchable.rb @@ -3,6 +3,7 @@ module Bubble::Watchable included do has_many :watches, dependent: :destroy + has_many :watchers, ->{ merge(Watch.watching) }, through: :watches, source: :user after_create :set_watching_for_creator end diff --git a/app/models/notifier.rb b/app/models/notifier.rb index 9c89d6bdf..10b1ba3c2 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -27,7 +27,7 @@ class Notifier end def recipients - bubble.watchers_and_subscribers.without(creator) + bubble.watchers.without(creator) end def resource diff --git a/app/models/notifier/published.rb b/app/models/notifier/published.rb index d5b50b87b..d43b8c8e3 100644 --- a/app/models/notifier/published.rb +++ b/app/models/notifier/published.rb @@ -1,2 +1,6 @@ class Notifier::Published < Notifier + private + def recipients + bubble.watchers_and_subscribers.without(creator) + end end diff --git a/app/models/user.rb b/app/models/user.rb index a79e4729e..57a8e636c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -31,7 +31,7 @@ class User < ApplicationRecord after_create_commit :grant_access_to_buckets scope :alphabetically, -> { order("lower(name)") } - scope :sorted_with_user_first, ->(user) { order(Arel.sql("id != ?, lower(name)", user.id)) } + scope :sorted_with_user_first, ->(user) { order(Arel.sql("users.id != ?, lower(name)", user.id)) } def initials name.to_s.scan(/\b\p{L}/).join.upcase diff --git a/app/views/bubbles/_messages.html.erb b/app/views/bubbles/_messages.html.erb index 5ddce595a..5a8eeea0e 100644 --- a/app/views/bubbles/_messages.html.erb +++ b/app/views/bubbles/_messages.html.erb @@ -7,7 +7,7 @@