Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lolaodelola/10232b63216a63c3987d160f6f77c017 to your computer and use it in GitHub Desktop.
Save lolaodelola/10232b63216a63c3987d160f6f77c017 to your computer and use it in GitHub Desktop.
namespace :affirmation do
task :send_text => :environment do |task, args|
  count = Affirmation.count
random_offset = rand(count)
affirmation = Affirmation.offset(random_offset).first
   Developer.confirmed.each do |dev|
     SendAffirmationJob.new.deliver(dev, affirmation)
     SentAffirmation.create!(developer_id: dev.id, affirmation_id: affirmation.id, sent_at: DateTime.now)
  end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment