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/”
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