Schedule Tasks Using ‘Whenever’ Gem- Ruby on Rails

Hima Chitalia
Sep 20, 2017 · 4 min read
Whenever Gem — Schedule rake tasks
rails g task my_namespace my_task
namespace :my_namespace do
desc “TODO”
task :my_task => :environment do
end
end
namespace :news do
desc “Rake task to get news article”
task :fetch => :environment do
puts “Updating news Articles…”
Article.getArticles()
puts “#{Time.now} — Success!”
end
end
ENV[‘RAILS_ENV’] = “development”set :output, ‘log/whenever.log’
every 1.day, :at => ‘10:20 am’ do
rake “news:fetch”
end

Coffee and Codes

All About Hooks of Coding!