开发者

Order polymorphic comments

shared/_comments.html.haml

#comments
  - commentable.comments.each do |comment|
    = link_to image_t开发者_如何学Cag(avatar_url comment.user_id,36), :controller => 'users', :action => 'show', :id => comment.user_id
    = comment.content
    %br

How to order polymorphic comments by 'created_at DESC' ?


In your model:

scope :by_created_at, order('created_at DESC')

Then in your view:

- commentable.comments.by_created_at.each do |comment|
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜