Cobwwweb logo

Disable Rake Commands in a Rails Project

May 15, 2015 Rake, Ruby on Rails

I had a project where I wanted to limit the use of db rake tasks to keep anyone from accidentally deleting the database.

To delete a rake task, simply add this method to your Rakefile:



Here task is the name of your task.

If you want to do this multiple times, you can loop over your tasks like so:


def remove_task(task)

tasks = ['db:drop', 'db:reset', 'db:setup', 'db:rollback', 'db:seed']
tasks.each { |t| remove_task(t) }

Did you learn something or find this article interesting?

If so, why not

Want to receive exactly one email every month with new articles, tools, and references I've discovered? Sign up below. (More info here.)