小编use*_*629的帖子

每当带有Rails的Heroku中的计划任务时

我需要在Heroku中运行计划任务.我在Rails的第一个cron工作!:-)

它在本地工作正常,但你如何使它在Heroku中工作?

我试过这个:heroku运行--update-crontab存储

但...

[失败]无法写crontab; 尝试运行`when',没有选项,以确保您的计划文件有效.

我还在Heroku的应用程序中添加了Heroku Scheduler.

这是我的config/schedule.rb

RAILS_ROOT = File.dirname(__FILE__) + '/..'
require File.expand_path(File.dirname(__FILE__) + "/environment")


every :day, :at => "11:00am" do
  @appointments = Appointment.where('date between ? and ?', Date.today, Date.today + 2.day)
  @appointments.each do |appointment|

    @emails = []

    @informated_people = InformatedPerson.where(person_id: appointment.person_id)
    @users = User.find(Authorization.where(:person_id => appointment.person_id).pluck(:user_id))
    @person = Person.find(appointment.person_id)

    @emails << @person.email

    @informated_people.each do |informated_person|
        @emails << informated_person.email
    end

    @users.each do |user|
        @emails << user.email
    end

    UserEmail.appointment_reminder_email(@emails.uniq, @person , 'Cita para el día ' + appointment.date.strftime("%d/%m/%Y …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails heroku whenever ruby-on-rails-4

4
推荐指数
1
解决办法
4104
查看次数

标签 统计

heroku ×1

ruby-on-rails ×1

ruby-on-rails-4 ×1

whenever ×1