Deleting all records in a database table
Deleting all records in a database table
It able to use delete_all is without SQL.
Post.delete_all
or
Post.delete_all "person_id = 5 AND (category = 'Something' OR category = 'Else')"
Delete via SQL:
Item.delete_all # accepts optional conditions
And delete by calling each model’s destroy method,
Item.destroy_all # accepts optional conditions
Completely empty the database and not just delete a model or models attached:
rake db:purge
test database.
rake db:test:purge