# ActiveResource with has\_many

**URL:** <https://www.ruby-forum.com/t/activeresource-with-has-many/106033>\
**Category:** Rails\
**Created:** [June 5, 2007, 8:46pm UTC](https://www.ruby-forum.com/t/activeresource-with-has-many/106033 "2007-06-05T20:46:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Wallace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/46a35a/32.png) [@Ryan\_Wallace](https://www.ruby-forum.com/u/Ryan_Wallace)\
**Post date:** [June 5, 2007, 8:46pm UTC](https://www.ruby-forum.com/t/activeresource-with-has-many/106033/1 "2007-06-05T20:46:35Z")

</div>

Hi all,

I am attempting to create a small app using ActiveResource but I am  
having trouble with relationships between models. It seems that  
ActiveResource doesn’t support has\_many relationships yet. Is there  
any way to return a single xml response which can be deconstructed  
into a set of related models, ie:

class Item \< ActiveRecord::Base  
has\_many :media\_links  
has\_many :media\_objects, :through =\> :media\_links  
end

class Item \< ActiveResource::Base  
self.site = “[http://localhost:3000/](http://localhost:3000/)”  
has\_many :media\_links  
has\_many :media\_objects, :through =\> :media\_links  
end

Using this ActiveResource model generates a ‘undefined method  
`has\_many’ for Item:Class’ error.

I am using the following find query on the ActiveRecord side:

```
@items = Item.find :all, :conditions => params[:conditions],
:limit => params[:limit],
:include => {:media_links => :media_object}

respond_to do |wants|
  wants.xml { render :xml => (@items).to_xml(:include

```

=\> :media\_objects)}  
end
