I have this little rake task:
namespace :db do
namespace :test do
task :reset do
ENV[\'RAILS_ENV\'] = \"test\"
Rake::Task[\'db:drop\']
Another option is to check the env and refuse to continue:
unless Rails.env.development?
puts "This task can only be run in development environment"
exit
end
or ask if they really want to continue:
unless Rails.env.development?
puts "You are using #{Rails.env} environment, are you sure? y/n"
continue = STDIN.gets.chomp
exit unless continue == 'y'
end