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|
精彩评论