TIL: Truncating tables in Rails
Today I learned that you can truncate tables in Rails.
| |
Quicker than Model.delete_all if you are clearing out a large table. The trade-off: truncate bypasses Rails callbacks and resets the auto-increment counter, so it’s only appropriate when you genuinely want to wipe the table and don’t need dependent deletions or validations to fire.