Fix for topic excerpt being from the wrong post

This commit is contained in:
Neil Lalonde 2013-05-18 13:35:21 -04:00
parent c5b2fd8067
commit 5f7f87437c
2 changed files with 2 additions and 1 deletions

View File

@ -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) }

View File

@ -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