我有以下内容,它应该做的是在每个月的 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'
我确定我的设置是正确的。如果有人可以帮我解决我搞砸的地方,谢谢。
医院预订
def self.send_overtime_mail(user, bookings)
OvertimeMailer.overtime_pdf(user, hospital_booking).deliver
end
调度器.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