Skip to content

Instantly share code, notes, and snippets.

@frankie-loves-jesus
Created November 11, 2014 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankie-loves-jesus/aa630c2131dec939bb70 to your computer and use it in GitHub Desktop.
Save frankie-loves-jesus/aa630c2131dec939bb70 to your computer and use it in GitHub Desktop.

Sorting Forem posts by DESC instead of ASC

Current: NO EFFECT

views/forem/topics/show.html.erb

<%= render partial: "forem/posts/post", collection: topic.desc_posts, locals: { topic: @topic } %>

decorators/models/forem/topic_decorator.erb

Forem::Topic.class_eval do
  def desc_posts
    posts.order("forem_posts.created_at DESC")
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment