Ruby on Rails Wednesday, July 7, 2010

On Jul 6, 7:27 pm, Joe <loret...@gmail.com> wrote:
> 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.
>

I usually stick a bunch of require_dependency calls at the bottom of
the file containing the base class that loads the various subclasses

Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment