User7354632781
User7354632781

Reputation: 2274

how to use whenever gem to send emails periodically

I have following condition in controller to trigger the email notification

controller.rb

 if !@data[:done]
   UserNotifier.send_email.deliver
 end

I want to send emails weekly so i am following the article below

https://gianthatworks.com/entry/using-the-whenever-gem-in-your-rails-app

I am at the step to add task in schedule.rb but if i do

every :sunday do
  UserNotifier.send_email.deliver
end

and run whenever in terminal then i get error

uninitialized constant #<Class:#<Whenever::JobList:0x007fb7fa1193d8>>::UserNotifier (NameError)

Any idea how do i update schedule.rb so i can send email only on sunday?

Thanks

Upvotes: 0

Views: 254

Answers (1)

User7354632781
User7354632781

Reputation: 2274

The only thing i was missing was this.

set :environment, "development"
set :output, {:error => "log/cron_error_log.log", :standard => "log/cron_log.log"}

Upvotes: 0

Related Questions