Skip to content

Commit d06c750

Browse files
committed
add_follower should prevent duplicate thread follower records
1 parent 74eaa4c commit d06c750

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/models/comment_thread.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ def maximum_title_length
9292
# @param user [User] user to register as a follower
9393
# @return [Boolean] status of the operation
9494
def add_follower(user)
95-
ThreadFollower.create(comment_thread: self, user: user)
95+
if ThreadFollower.where(comment_thread: self, user: user).none?
96+
ThreadFollower.create(comment_thread: self, user: user)
97+
end
9698
end
9799

98100
# Directly bumps the thread's last activity date & time

0 commit comments

Comments
 (0)