Model.find(:last)

Posted on October 15, 2007

This took me a while to figure out tonight, but it may be old hay for other Rails hackers, so here it is: if you want to find out the ‘last’ id in a table, use this:

Model.find(:first, :o rder => ‘id desc’)

Pretty easy. Too bad Model.find(:last) doesn’t work.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

Comments