Forum: Ruby on Rails ActiveResource: a tag that has the same name as an existing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2007-02-07 03:00
(Received via mailing list)
I've got an ActiveRecord::Base class named Tracker.  I've also got an
ActiveResource class named MyConfig that will read an xml file that
looks like:

<my-config>
  <tracker>
    <name>foo</name>
  </tracker>
</my-config>

class MyConfig < ActiveResource::Base
  self.site = "http://localhost"
end

If I do MyConfig.find(1), I get:

NoMethodError: undefined method `name=' for #<Tracker:0x2487378>

ARes apparently creates new classes for all these sub-elements, and it
does them in the MyConfig context (so it should make
MyConfig::Tracker).  If I type MyConfig::Tracker into the console, I
get
>> MyConfig::Tracker
(irb):13: warning: toplevel constant Tracker referenced by
MyConfig::Tracker
=> Tracker

Why is it doing this?  And how do I fix it?  I need to keep my Tracker
ActiveRecord class, and the xml file has to have the <tracker>
element.

Pat
This topic is locked and can not be replied to.