The project is in a healthy, maintained state
A Rails gem that overrides ActiveRecord's destroy_all method to ask for confirmation before deleting records.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0
~> 1.4
 Project Readme

Gem ConfirmDestroyAll

A Rails gem that overrides ActiveRecord's destroy_all method to ask for confirmation before deleting all records using .destroy_all.

The purpose of the gem is to provide you with a confirmation screen to avoid deleting all records from the database. The idea is to prevent the .destroy_all command from being executed in a PRODUCTION environment.

Installation

Add this line to your Gemfile:

group :production do
  gem 'confirm_destroy_all'
end

And then execute:

$ bundle

Usage

When you are in a Ruby console and need to destroy multiple records, run rails console:

$ rails console
Loading production environment (Rails 7.0.6)

irb(main):001> MyModel.destroy_all

You are in the PRODUCTION environment:
Are you sure you want to destroy all records for MyModel? Type 'yes' to proceed:

This will prevent you from running .destroy_all in a production environment without first confirming that this is what you really want.

Test

To run all rspec tests:

$ spec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/leonidasamorim/confirm_destroy_all. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.