我有以下内容,它应该做的是在每个月的18日生成一份应该做的报告。刚刚注意到一个小问题。我收到以下错误
undefined local variable or method hospital_booking
也指向以下内容:
app/models/hospital_booking.rb:30:in `send_overtime_mail'
app/controllers/hospital_bookings_controller.rb:11:in `index'
我确定我的设置是正确的。如果有人可以帮助我,我已经搞砸了谢谢。
HosptialBooking
def self.send_overtime_mail(user, bookings)
OvertimeMailer.overtime_pdf(user, hospital_booking).deliver
end
Scheduler.rake
desc 'Send hospital bookings overtime report'
task :overtime_report => :environment do
if Date.today.day == 18
bookings = HospitalBooking.where(:day => Date.today.beginning_of_month..Date.today.end_of_month)
user = User.where(:roles => :administrator).first
OvertimeMailer.overtime_pdf(user, hospital_bookings).deliver
end
end
答案 0 :(得分:1)
send_overtime_mail
将参数转换为bookings
变量,然后您在方法中使用hospital_booking
。
def self.send_overtime_mail(user, bookings)
OvertimeMailer.overtime_pdf(user, bookings).deliver
end
应该有用。