Hey guys, I''m trying to copy the entire content of table "actives" to the table "olds". What I''ve done in the past is use regular SQL statements, but I''d like to make my code more Ruby-ish I suppose. Using SQL, I would usually run a DELETE FROM olds to clear that table, then iterate over everything in the actives table and copy it over to the olds table. Is there a better way to do this, especially now that I''m using ActiveRecord? Thanks! - Jeff -- Posted via http://www.ruby-forum.com/.
Seriously, The best way to ahieve this is in a stored procedure in the database. Just create a method on your model class that will run the stored proc, that way your controllers and rake tasks etc... can have access to the functionality if you want them to . Let the database do the job it''s designed to do and let your models do their bit, you will get a much better performance. -- Posted via http://www.ruby-forum.com/.
Jeff Miller wrote:> Hey guys, > I''m trying to copy the entire content of table "actives" to the table > "olds".[...] Why are you bothering? If this is simply a question of filtering inactive records, you probably should just have a flag for that. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.