Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

adamcooke/rails-safe-tasks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Rails Safe Tasks

This gem provides an extra layer of safety between you and deleting all your production data by accident.

It restricts the use of various rake tasks (including db:drop, db:reset etc...) when you are running your application in a production environment.

Screenshot

Installation

To install, just add to your Gemfile and run bundle.

gem 'rails_safe_tasks', '~> 1.0'

Usage

You don't need to do anything to get started but you can add some extra configuration if you wish.

# Add another task to the list of dangerous tasks
RailsSafeTasks.dangerous_tasks << 'another:task'

# Also can add your own custom environment to the list of restricted
# environments.
RailsSafeTasks.restricted_environments << 'SOME_ENV'

# Specify a custom rule for checking whether or not the current environment
# should be protected or not. Return true if the current environment should
# be protected. In this example, the presence of the 'VDT_APP' environment
# variable means we should be in a cautious state.
RailsSafeTasks.custom_check do
  !!ENV['VDT_APP']
end

# Protect a task which is not already initialized when the Gem is included.
namespace :my_app do
  task :wipe_everything do
    # Here be dragons...
  end
end

Rake::Task['my_app:wipe_everything'].enhance ['rails_safe_tasks:disable']

About

Automatically disable dangerous Rake tasks in production

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages