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?
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?
Bob S. 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 could exclude the highest possible id, with :conditions => " id !=
max(id) "
-john
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs