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