Reputation:
I have the following and what it is supposed to do is generate a report on the 18th of every month which is what is supposed to do. Just noticed a small problem. I am getting the following error
undefined local variable or method hospital_booking
that also points to the following:
app/models/hospital_booking.rb:30:in `send_overtime_mail'
app/controllers/hospital_bookings_controller.rb:11:in `index'
I am certain my setup is correct. If someone can give me a hand in where I have messed up thanks.
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
Upvotes: 0
Views: 77
Reputation: 222108
send_overtime_mail
takes the parameter into bookings
variable, and then you're using hospital_booking
inside the method.
def self.send_overtime_mail(user, bookings)
OvertimeMailer.overtime_pdf(user, bookings).deliver
end
should work.
Upvotes: 1