我有关于链接信息的表格。但我只能按创建日期和名称排序。如何对属于链接的项目进行排序?
def links_all
per_page = 60
Links.limit(per_page).offset( (@page - 1) * per_page ).order(@sort_column + " " + @sort_direction).map do |s|
{
:name => s.name,
:item_num => s.items.count,
:comments_num => s.comments.count,
:user_name => s.user ? s.user.name : "" ,
:created_at => s.created_at.to_formatted_s(:db) ,
:user_id => s.user ? s.user.id : "" ,
:streme_id => s.id,
:streme_views => s.views ? s.views : ""
}
end
end