rctneil
rctneil

Reputation: 7210

Access Controller from Job in Rails

I have a Rails Active Job job, but as part of that job I need to call a method from another Controller. I have tried like below but it fails.

Admin::Gallery::GalleryController.assign_albums_to_collections

Is this possible and how? If not then what is recommended?

Upvotes: 0

Views: 570

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230346

Not possible*. Extract that logic from a controller into another class, so you can call it from both controller and job.


*unless assign_albums_to_collections is a class instance method on the controller

Upvotes: 4

Related Questions