You could achieve that with the following rake task (which i found here time ago)
namespace :db do
desc "Truncate all tables"
task :truncate => :environment do
conn = ActiveRecord::Base.connection
tables = conn.execute("show tables").map { |r| r[0] }
tables.delete "schema_migrations"
tables.each { |t| conn.execute("TRUNCATE #{t}") }
end
end
Edited to add a link to the question i found before:
Delete everything from all tables (in Activerecord)
I don't understand why you want to drop all tables if the truncate instruction also make a fresh start of your table.
Anyway, maybe this answers could be helpful too:
https://stackoverflow.com/a/2789515/1639291
https://stackoverflow.com/a/1197218/1639291