Skip to content

Instantly share code, notes, and snippets.

@krzykamil
Created September 23, 2020 06:57
Show Gist options
  • Save krzykamil/3ef2fdfa77d2ef7811303052c8d75550 to your computer and use it in GitHub Desktop.
Save krzykamil/3ef2fdfa77d2ef7811303052c8d75550 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
desc "example task"
task :example_task, [:for_real] => [:environment] do |task, args|
ActiveRecord::Base.transaction do
# This is the way, do your thing here
unless args[:for_real] == "for_real"
raise "Discarded all changes. To do a real run invoke this task as follows:
bundle exec rake \"#{task.name}[for_real]\"\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment