Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 Rails 中的菜鸟,我正在遵循 Rails 官方文档来创建博客,在使用帖子和评论控制器创建博客后,我想添加一些方法来根据时间戳显示帖子,即最后创建的帖子或有人评论过的帖子在该帖子上显示在列表顶部。请提出一种方法或一些宝石来实现这一目标。
使用orderactiverecord 的。假设您的博客模型是Blog
order
Blog
Blog.order("updated_at DESC")
检查教程
您还可以创建范围