Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 

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