抄自这里
直接贴代码
# lib/tasks/skip_prod.rake desc 'Raises exception if used in production' task skip_prod: [:environment] do raise 'You cannot run this in production' if Rails.env.production? end
# lib/tasks/db.rake ['db:drop', 'db:reset', 'db:seed'].each do |t| Rake::Task[t].enhance ['skip_prod'] end