im having a problem using the gem whenever v0.8.4. The config/schedule.rb
looks like this:
every :day, :at => '8am' do
runner "TimeclockReportSender.sendReports"
end
The thing is the TimeclockReportSender.sendReports
code does not execute. The file is in /vendor/plugins/plugin_name/lib/reports/timeclock_report.rb
.
Im developing at a rails 2.3.5 project, using redmine 1.1.1. Any one knows how i can specify the whenever to execute the plugin module code or if i must put this piece of code elsewhere.
UPDATE
module TimeclockReportSender
require "reports/timeclock_report.rb"
#verify and send every report that has date_to_send == today
def self.sendReports
reports = CtTimeclockReport.find(:all)
reports.each do |rpt|
if !rpt.date_to_send.nil?
if rpt.date_to_send.to_date() == Date.today
users = CtTimeclockReport.getAllUsersFromReport(rpt)
period = CtSettingsPeriod.getPeriod(rpt.ct_settings_period_id)
project = Project.find(period.project_id)
pdf = TimeclockReport.createAndGetReport(rpt,project)
sent = TimeclockReportSender.sendReport(rpt,pdf,users)
TimeclockReportSender.updateReportDate(rpt)
end
end
end
end
#send a single report pdf via email to the users list
def self.sendReport(report,pdfReport,users)
#send the report to each user
users.each do |usr|
usr = User.find(usr.user_id)
if !usr.nil?
CtMailer.deliver_reportEmail(report,pdfReport,usr)
end
end
return true
end
when i run the command:
script/runner -e production '\''TimeclockReportSender.sendReports'\'''
at rails root, it asks me some input ... this command it
s the crontab generated from whenever
UPDATE2
To run the sendReports method, i must require the file in my controller using
require "reports/timeclock_report_sender.rb"
FIXED
I ran the cmd from cron and found out that rails was not finding my module. The solution was to put the code inside a Model from my plugin, than it found his code. Thanks 4 all :D
Problem solved! I found out that the reason why it was not executing by running the cmd from cron and then i found out that rails was not finding my module.
The solution was to put the code inside a Model from my plugin, than cron found his code. Thanks for the help guys.