1

I'm upgrading a rail2 app to rails3, and experiencing some weird behavior with the way ActiveResource is consuming a REST api (also a rails app). The XML response from the api looks something like:

<company>
    <name>Company Name</name>
    <employee>
        <name>Employee 1</name>
        <position>
            <name>Manager</name>
        </position>
    </employee>
</company>

Now I am able to consume the api correctly, and dot notation seems to work fine...i.e.:

company.employee.name #returns Employee 1

However, I noticed that the class type of nested attributed is different than it was in rails 2. In rails two, the class types (based on the XML above), would be:

Company
Employee
Position

However, in rails 3, the class types are:

Company
Company::Employee
Company::Employee::Position

For some reason, it is namespacing the classes. I have already defined each of the ActiveResource classes for each of these types (non-namespaced), and because rails3 is namespacing things, it is not mapping to the classes I have defined.

Anyone know if there is a way to turn this off?

gmoniey
  • 7,975
  • 4
  • 27
  • 30

1 Answers1

1

Took some digging around, but I discovered that this is because the models have not been loaded yet.

I've filed a ticket here (with a temporary workaround): https://github.com/rails/rails/issues/5148

gmoniey
  • 7,975
  • 4
  • 27
  • 30