invite to edit notifications marked as read in system once map is visited

This commit is contained in:
Devin Howard 2016-12-09 11:59:24 -05:00
parent 5eb6435543
commit 7aa19365a1
2 changed files with 7 additions and 0 deletions

View file

@ -8,6 +8,7 @@ class MapsController < ApplicationController
def show def show
respond_to do |format| respond_to do |format|
format.html do format.html do
UserMap.where(map: @map, user: current_user).map(&:mark_invite_notifications_as_read)
@allmappers = @map.contributors @allmappers = @map.contributors
@allcollaborators = @map.editors @allcollaborators = @map.editors
@alltopics = policy_scope(@map.topics) @alltopics = policy_scope(@map.topics)

View file

@ -2,4 +2,10 @@
class UserMap < ApplicationRecord class UserMap < ApplicationRecord
belongs_to :map belongs_to :map
belongs_to :user belongs_to :user
def mark_invite_notifications_as_read
Mailboxer::Notification.where(notified_object: self).each do |notification|
Mailboxer::Receipt.where(notification: notification).update_all(is_read: true)
end
end
end end