Home access all events from clockwork manager to controller
Reply: 1

access all events from clockwork manager to controller

Raj kumar
Raj kumar Published in 2017-12-30 08:03:19Z

Am using gem clockwork for running scheduled jobs. I need to access all events defined in clock.rb for manually trigger the clockwork events when it fails.

For that I forked the clockwork gem by adding attr_reader: events in clockwork/manager.rb file.


module Clockwork
  every(10.seconds, 'job1') do
    p Clockwork.manager.events

By using Clockwork.manager.events in clock.rb it returns all events that defined in clock.rb.


module Admin
  class MyController < AdminController

    require 'clockwork'

    def index
      @events = Clockwork.manager.events

But while using it in controller it returns empty value.

How to get all clockwork events in controller?

ahmeij Reply to 2018-01-02 11:23:39Z

In development mode not all application code is loaded during startup, likely the code where you defined your events is not loaded yet.

You can require that specific file in your controller, afterwards they should be visible.

In production mode all code is loaded during startup so in that mode it should already work.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.400999 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO