Feature: ActiveResource - Adding associations through reflections

Hello everyone,

I'm new in contributing and i saw in the contributing-guides, that i have to write an email at this list. I hope, that's the right place for this. If it's not, i'M really sorry.. :wink:

Could someone please give me feedback about this lighthouse-ticket? https://rails.lighthouseapp.com/projects/8994/tickets/6473-activeresource-adding-associations-through-reflections

It's about adding association-definitions in ActiveResource.

Thank you for reading this Mail.

Greetings Markus Schwed

Hi Markus,

can associated records be created, using accepts_nested_attributes_for ?

That would be awesome!

Hi Antonio,

at the moment there is only the possibility to specify the class-name for an associated resource via :class_name - option.

We added the association-definitions similar to the ActiveRecord-way with own Reflection-classes, because we want to add some cool features in the future. Indeed, your idea with accepts_nested_attributes_for for create and update is really good and could be on of these features to add.

Please visit the ticket, apply the patch and give feedback, that would be very helpful.

Greetings Markus

Hi

In fact, we would extend active resource with more restful features. At the moment, a class-definition with has_many, has_one gives you the posibility to have a resource with self associations. For example: an Comment can have other comment and so on.

but for such a restful consume of a web service. a association over id's isn't precice enougth. we would build soon a resolver of link-tag in the data structure.

for exampple, a post has many comments, the classical way to define a association is following: GET posts/1.xml <post> .. </post>

GET posts/1/comments.xml <comments> <comment>   <post-id>1</post-id> </comment> </comments>

but you must have knowlege over the api server side. you must know the url where you found the comments. my prefered way for complexe api structures are link-tags like atom- syndication-format. GET posts/1.xm <post>   <link type="comment" href="comments/1"> <post>

you don't need to know who the comments are, the posts gives his associated objects. every instance in restful apis should be selfdescribed.

summary, we would make activeresource smarter for the way, its consume services and resolve associations and save performance.

at first, we would focus on this. smarter client usage is point two for us masterplan :smiley: