Find the newest record in Rails 3

后端 未结 5 586
眼角桃花
眼角桃花 2020-12-03 09:45

I was wondering if theres a way to find the newest record in a table in rails3?

Thanks

Elliot

5条回答
  •  失恋的感觉
    2020-12-03 09:54

    Yes, you can use the method .last

    So if your model is called Post then:

    >> Post.last
    => #
    

提交回复
热议问题