Bob Sanders
2008-Mar-22 20:57 UTC
How do I find all entries, except the newest entry, created?
I''m looking to do a Post.find(:all) -- finding all entries but the newest one created. Maybe something in this format, although I''m not sure: Post.find(:all, :order => "created_at DESC", :conditions => "**EXCLUDE NEWEST ENTRY CREATED**"]) Any idea? -- 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 -~----------~----~----~----~------~----~------~--~---
rubynuby
2008-Mar-22 21:12 UTC
Re: How do I find all entries, except the newest entry, created?
Bob Sanders wrote:> I''m looking to do a Post.find(:all) -- finding all entries but the > newest one created. Maybe something in this format, although I''m not > sure: > > Post.find(:all, :order => "created_at DESC", :conditions => "**EXCLUDE > NEWEST ENTRY CREATED**"])I don''t think you can do with a SQL. Just find all and get rid of it. Post.find(:all), :order=>''created_at DESC'').shift or Post.find(:all), :order=>''created_at'').pop --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
John Adams
2008-Mar-22 22:13 UTC
Re: How do I find all entries, except the newest entry, created?
You could exclude the highest possible id, with :conditions => " id != max(id) " -john On Mar 22, 2008, at 2:12 PM, rubynuby wrote:> > > > Bob Sanders wrote: >> I''m looking to do a Post.find(:all) -- finding all entries but the >> newest one created. Maybe something in this format, although I''m not >> sure: >> >> Post.find(:all, :order => "created_at DESC", :conditions => >> "**EXCLUDE >> NEWEST ENTRY CREATED**"]) > > I don''t think you can do with a SQL. Just find all and get rid of it. > > Post.find(:all), :order=>''created_at DESC'').shift > > or > > Post.find(:all), :order=>''created_at'').pop >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---