@Robert, @Fred, @Max

GOT IT!  You all had a piece of the puzzle.

(Robert: As an aside, you mean "you call Product.descendants()" -- not 
dependencies() -- but that's a trifle.)

I realized that my reason that the Fred/Robert solution didn't work was 
correct: a request passes in the string "PGEBusiness", and the 
controller code does something like:

file: metered_services_controller.rb
  def create
    ...
    class_name = params["metered_service"]   # e.g. "PGEBusiness"
    @metered_service = Object.const_get(class_name).new( ... )
    ...
  end

Notice there's nothing there that forces a load of MeteredService, so 
the calls to require_dependency() at the bottom of metered_service.rb 
aren't invoked.  But I can force a load of metered_service.rb by a call 
to descendants():

  def create
    ...
    MeteredService.descendants()
    class_name = params["metered_service"]   # e.g. "PGEBusiness"
    @metered_service = Object.const_get(class_name).new( ... )
    ...
  end

And that works.  *phew*  Thanks for your patience.

- ff

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to