ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
end
Hope this helps.
Thanks,
Abhinav
--
अभिनव
http://twitter.com/abhinav
On Tue, Sep 22, 2009 at 8:34 PM, Heinz Strunk <
[email protected]> wrote:
>
> Hey,
>
> thanks for the link. I'll have a look at it later. Well I know of
> Mytable.delete_all but I have like 40 tables already and find it a bit
> annoying to write them down by hand. I'm looking for some function that
> iterates through all my tables and truncates them.
>
> Something like:
> Blabla.allTablesOrModels.each do |t|
> t.delete_all
> end
> --
> 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
-~----------~----~----~----~------~----~------~--~---