undefined局部变量或方法`hospital_booking

时间:2013-05-17 09:11:49

标签: ruby-on-rails ruby-on-rails-3

我有以下内容,它应该做的是在每个月的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 

1 个答案:

答案 0 :(得分:1)

send_overtime_mail将参数转换为bookings变量,然后您在方法中使用hospital_booking

def self.send_overtime_mail(user, bookings)
  OvertimeMailer.overtime_pdf(user, bookings).deliver
end

应该有用。