order comments by the most recent first

This commit is contained in:
David Gil
2015-08-11 20:27:37 +02:00
parent 9d2bece0b3
commit 44d4fa9fc4
5 changed files with 11 additions and 9 deletions

View File

@@ -8,6 +8,8 @@ class Comment < ActiveRecord::Base
belongs_to :commentable, polymorphic: true
belongs_to :user
scope :recent, -> { order(id: :desc) }
def self.build(commentable, user, body)
new commentable: commentable,
user_id: user.id,