RVince wrote: > I have a table where I am trying to delete all but the 10 most recent > records. My code is as follows: > > cnotes = Channelnote.find(:all, :order => 'tstamp DESC', :limit => > 10, :conditions => ["deleted=0"]) > Channelnote.delete_all; > for cnote in cnotes do > g=cnote.save > end
This is terrible logic. In another thread, I gave you a sample SQL query for only deleting the records you actually want deleted. I strongly suggest that you do it that way instead of deleting everything and then writing stuff back in. Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

