In my project, I have a user model. The user model can be assigned chores. Chores have an associated class object (that go by the name 'Service'). In the admin interface for users, the administrator can assign these Chores to a user, and when they do this, they select the Service for the Chore from a dropdown. My problem is getting the service list.
All service classes inherit from Services::Base (MyService < Services::Base) I want to provide the list of available services in that dropdown, but when in development mode, the classes are unloaded and reloaded with each request. Thus, using Object.subclasses_of( Services::Base ) will not reliably get me a list of available services, as the classes have probably been unloaded by the time the code is reached.
Alternatively, I wanted to register available services via an initializer, like: add_service MyService, but this depends on storing values in a class, which also fails, for the same reason, as far as I can tell (because the classes are being unloaded after each request).
Note, both of these methods work fine in test and production mode.
If there is any other information I can provide, please let me know. Thanks all for the help.