dimanche 14 novembre 2021

Rails 3 uninitialized constant when using thread

i am running rails 3 thread to improve the performance of the rake task. sometimes i am getting uninitialized constant when i am trying to access outside class from my current class. as an example when i am trying to access NotificationService class from NotificationApp as shown below then getting error as uninitialized constant NotificationService. This error is not coming every time. sometimes rake task is running fine without the error and sometimes same rake is failing with uninitialized constant. what could be the reason for this and how can i fix this issue?

class NotificationApp < ActiveRecord::Base
  def signal_event
    NotificationService.notify
  end
end

Aucun commentaire:

Enregistrer un commentaire