Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveResource - Adding associations through reflections

#6473

Hello there,

Matthias Folz and I have added the 'has_many' and 'has_one' - associations through reflections in ActiveResource.

Now, It's possible to specify the class for a "Child-Resource" via :class_name - option in has_many and has_one - association definition.

We choosed the way through reflections, because in we plan to add some other cool features for associations like 'autoload' in ActiveResource.

For example:

GET /posts/123.xml delivers following response body:

<post>
  <title>ActiveResource now have associations</title>
  <content> ... </content>
  <comments>
    <comment> ... </comment>
    <comment> ... </comment>
  </comments>
</post>

has_many :comments, :class_name => ‘myblog/comment‘

Would resolve this comments into the Myblog::Comment class.

Greetz and thanks a lot for viewing this ticket!
Markus Schwed

Reported by Markus Schwed · February 26th, 2011 @ 05:24 PM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Gaston Ramos
    Gaston Ramos

    I have sent a pull request that add the same that your patch see: https://github.com/rails/rails/pull/70

    March 1st, 2011 @ 09:10 AM

  2. Gregor Melhorn
    Gregor Melhorn

    Looks like a good useful feature. +1

    March 2nd, 2011 @ 09:07 AM

  3. Michael Raidel
    Michael Raidel

    This would be a very useful feature. +1

    March 9th, 2011 @ 08:49 PM

  4. bingbing