How to get last N records with activerecord?

前端 未结 14 681
南旧
南旧 2020-12-12 11:43

With :limit in query, I will get first N records. What is the easiest way to get last N records?

14条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-12 12:05

    new way to do it in rails 3.1 is SomeModel.limit(5).order('id desc')

提交回复
热议问题