Currently we have a method in application_controller.rb
which initialises a global variable or returns its value if it has been initialized.
Problem is this is being called upon each request, and its redundant because the variable is initialized after the first request.
How can I move this method to application.rb
and have it run once upon Rails' initialisation
config.after_initialize do
begin
@global_user = User.find(100)
rescue => e
Rails.logger.info "Error finding the Global User"
end
end
Aucun commentaire:
Enregistrer un commentaire