mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:44:49 +08:00
Fix for topic excerpt being from the wrong post
This commit is contained in:
parent
c5b2fd8067
commit
5f7f87437c
|
@ -39,6 +39,7 @@ class Post < ActiveRecord::Base
|
|||
SHORT_POST_CHARS = 1200
|
||||
|
||||
scope :by_newest, order('created_at desc, id desc')
|
||||
scope :by_post_number, order('post_number ASC')
|
||||
scope :with_user, includes(:user)
|
||||
scope :public_posts, -> { joins(:topic).where('topics.archetype <> ?', Archetype.private_message) }
|
||||
scope :private_posts, -> { joins(:topic).where('topics.archetype = ?', Archetype.private_message) }
|
||||
|
|
|
@ -60,7 +60,7 @@ class TopicListItemSerializer < ListableTopicSerializer
|
|||
end
|
||||
|
||||
def excerpt
|
||||
object.posts.first.try(:excerpt,220, strip_links: true) || nil
|
||||
object.posts.by_post_number.first.try(:excerpt, 220, strip_links: true) || nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user