Skip to content

Instantly share code, notes, and snippets.

@thbar
Last active December 5, 2021 22:39
Show Gist options
  • Select an option

  • Save thbar/4550834 to your computer and use it in GitHub Desktop.

Select an option

Save thbar/4550834 to your computer and use it in GitHub Desktop.
Using ActiveRecord logger and transaction rollback to review data processing task before going live
namespace :data do
task :console_logger do
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
task :do_some_tweaking, [:user_email, :confirmation] => [:environment, :console_logger] do |t, args|
User.transaction do
# ...
raise "Rolling back after dry run - add CONFIRM to confirm!" unless args[:confirmation] == 'CONFIRM'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment