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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---