Rails does not work

I am using the gem 'clockwork' in a Rails 3.2 application. The application runs on Heroku. Work with the clock is performed at 1:00 - but this is not code execution.

Here is the clock.rb code:

Clockwork.every(1.day, 'DailyJob', :at => '01:00'){ StatsMailer.stats_email.deliver Forecast.where(:run_date => Date.today).each do |forecast| woschedules_run_jobplans_path(:id => forecast.woschedule_id) end } 

The log displays:

Sep 04 00:00:05 ndeavor-staging app / clock.1: # <NoMethodError: undefined `woschedules_run_jobplans_path 'method for Clockwork: Module>

If I rake routes, I get:

 woschedules_run_jobplans GET /woschedules/run_jobplans(.:format) woschedules#run_jobplans 
+8
ruby ruby-on-rails heroku clockwork
source share
1 answer

The error is that the route does not exist. Since a route exists, this problem usually means that Rails routes have not been loaded into the current scope.

You may need to enable Rails route helpers to work properly: Rails.application.routes.url_helpers

 Clockwork.every(1.day, 'DailyJob', :at => '01:00'){ StatsMailer.stats_email.deliver Forecast.where(:run_date => Date.today).each do |forecast| # Prepend your route with the following: Rails.application.routes.url_helpers.woschedules_run_jobplans_path(:id => forecast.woschedule_id) end } 

Alternatively, to dry it a bit, you can simply include all route helpers at the beginning of the file using:

 # Beginning of file include Rails.application.routes.url_helpers # ... 
+7
source share

All Articles