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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 okt 2008, at 21:13, 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 = :lastAd.find :first, :order => "updated_at DESC", :limit => 1 cheers, bartz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Does this work? Ad.find(:first, :order => "updated_at DESC") -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Abel Sent: Friday, October 03, 2008 12:14 PM To: Ruby on Rails: Talk Subject: [Rails] Find last record updated 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Roy and Bart. Both sentences work and return the same record. On Oct 3, 9:16 pm, Bart Zonneveld <zuperinfin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3 okt 2008, at 21:13, 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 > > Ad.find :first, :order => "updated_at DESC", :limit => 1 > > cheers, > bartz--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 = :lastHow about Ad.find :first, :order => ''updated_at DESC'' -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---