I have the tables (Maybe they’re not called that) Users and Posts. I added a lot of tests posts to the Posts table (maybe it’s called a database) so I want to wipe it. I know that I could use rake db:reset but that would also wipe the Users table.
Does anyone know how to reset only a specific table?
You might be better off creating a rake task for this. You could even namespace it inside of ‘db’ if you wanted. ie
rake db:reset_unimportant_modelsIn that task u can then do something like:
ModelName.delete_allFor more info on delete_all check here: http://apidock.com/rails/ActiveRecord/Relation/delete_all
For more info on creating rake tasks, check here: http://jasonseifer.com/2010/04/06/rake-tutorial
Here is an example of what you might do:
You would then call that like:
rake db:reset_unimportant_modelsand when you run
rake -Tu will see it up with the db:blah tasks