Skip to content

Instantly share code, notes, and snippets.

@knewter
Created June 28, 2011 13:48
Show Gist options
  • Save knewter/1051166 to your computer and use it in GitHub Desktop.
Save knewter/1051166 to your computer and use it in GitHub Desktop.
# Here's what the scope was before
scope :by_most_recent_post, joins(:posts).order('forem_posts.created_at DESC, forem_topics.id').group('topic_id')
scope :by_pinned_or_most_recent_post, includes(:posts).
order('forem_topics.pinned DESC').
order('forem_posts.created_at DESC').
order('forem_topics.id')
# Here's what it likely should be, based on the by pinned or most recent scope
scope :by_most_recent_post, includes(:posts).order('forem_posts.created_at DESC)
scope :by_pinned_or_most_recent_post, includes(:posts).
order('forem_topics.pinned DESC').
order('forem_posts.created_at DESC').
order('forem_topics.id')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment