Skip to content

Instantly share code, notes, and snippets.

@stevencch99
Created June 9, 2019 08:22
Show Gist options
  • Save stevencch99/6e18f54567e291e95ec2e27b4b433de8 to your computer and use it in GitHub Desktop.
Save stevencch99/6e18f54567e291e95ec2e27b4b433de8 to your computer and use it in GitHub Desktop.
namespace :db do
desc 'Reset counter cache of tasks count in project.'
task update_tasks: :environment do
print '開始更新任務數'
Project.all.each do |p|
Project.reset_counters(p.id, :tasks)
print '.'
end
puts '更新完成!'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment