]> git.openstreetmap.org Git - rails.git/commitdiff
Switches from comments to all_comments
authorNenad Vujicic <nenadus@gmail.com>
Tue, 4 Feb 2025 15:36:58 +0000 (16:36 +0100)
committerNenad Vujicic <nenadus@gmail.com>
Thu, 6 Feb 2025 09:58:52 +0000 (10:58 +0100)
Switches from using note's .comments to .all_comments. Fixes bug with notes of deleted users without comments, which are filtered out, but the code tries to access the first comment.

app/models/note.rb

index d37b863e53b5a77224375fc48990860144171cfe..807ee9ec8b99a7e021ac9ba8b46963c2f74cd2a8 100644 (file)
@@ -94,7 +94,7 @@ class Note < ApplicationRecord
   # Return the note's description, derived from the first comment
   def description
     if user_ip.nil? && user_id.nil?
-      comments.first.body
+      all_comments.first.body
     else
       RichText.new("text", super)
     end
@@ -103,7 +103,7 @@ class Note < ApplicationRecord
   # Return the note's author object, derived from the first comment
   def author
     if user_ip.nil? && user_id.nil?
-      comments.first.author
+      all_comments.first.author
     else
       super
     end