TIL: Truncating tables in Rails

Posted on Feb 9, 2021

Today I learned that you can truncate tables in Rails.

1
ActiveRecord::Base.connection.truncate(Model.table_name)

Certainly quicker than MODEL.delete_all if you are clearing out a large table.