Hi,
I need to implement a notification feature in my project. My user model
has
a daily, weekly and monthly booleans fields. I already have a UserMailer
that sends mail when I create an account, or for password resetting.
What I want is my app to send a mail each day or week or month,
depending
on what the user chose.
So I’ve installed Whenever gem https://github.com/javan/whenever, and
here is my schedule.rb :
every :day, :at => ‘12pm’ do # Use any day of the week or :weekend,
:weekday rake “email_sender”
end
My rake task :
desc “Send email to users”
task :email_sender => :environment do |_, args|
User.find_each do |user|
UserMailer.daily_mail(user).deliver if user.daily == true
end
end
My UserMailer :
def daily_mail(user)
@user = user mail to: user.email, subject: “Mail journalier”
end
The thing is, I don’t know if I did right, and how can I test this,
since
I’m not in development ?
I did a crontab -l and I get this :
Begin Whenever generated tasks for: store
0 12 * * * /bin/bash -l -c ‘cd /Users/Marco/Documents/TBProject &&
RAILS_ENV=production bundle exec rake email_sender --silent’
End Whenever generated tasks for: store
Begin Whenever generated tasks for:
/Users/Marco/Documents/TBProject/config/schedule.rb
0 12 * * * /bin/bash -l -c ‘cd /Users/Marco/Documents/TBProject &&
RAILS_ENV=production bundle exec rake email_sender --silent’
End Whenever generated tasks for:
/Users/Marco/Documents/TBProject/config/schedule.rb
If you could help me please