Forum: Ruby on Rails Find last record updated

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Abel (Guest)
on 2008-10-03 23:14
(Received via mailing list)
I always get confused when I have to make a search with Active Record
a little beyond the most ordinaire. How do I find the record that was
updated the last?
It has to be something like

Ad.find :conditions => updated_at = :last

I just don't know how to code it.
Raja V. (Guest)
on 2008-10-05 12:24
Abel wrote:
> I always get confused when I have to make a search with Active Record
> a little beyond the most ordinaire. How do I find the record that was
> updated the last?
> It has to be something like
>
> Ad.find :conditions => updated_at = :last

How about
Ad.find :first, :order => 'updated_at DESC'
This topic is locked and can not be replied to.