We use whenever a gem with rails in our project. I understand that we can plan a team using whenever this happens.
every 1.day, :at => '6:00 am' do command "echo 'hello'" end
but my problem is that I want to execute this command only if some condition is met. something like that.
every 1.day, :at => '6:00 am' do if User.any_new_user? command "echo 'hello'" end end
how can we achieve this every time and with rails? One of the possible solutions that I can think of is that I create a runner for this and check this condition. Sort of:
every 1.day, :at => '6:00 am' do runner "User.say_conditional_hello" end
and inside my user model:
def self.say_conditional_hello `echo "Hello"` end
Any suggestions for this approach or any new approach will be really helpful.
Thanks in advance!
source share