# ActiveResource server

**URL:** <https://www.ruby-forum.com/t/activeresource-server/138191>\
**Category:** Rails\
**Created:** [May 20, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/activeresource-server/138191 "2008-05-20T23:35:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [May 20, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/activeresource-server/138191/1 "2008-05-20T23:35:59Z")

</div>

Can anyone point me to documentation, how to’s, etc about how to create  
an active resource server. I get its trivial to create a client. But  
I’m wanting to create a server that can be used by input forms and also  
by an active resource client.

The big mystery to me is how (or if) the xml coming in from an active  
resource client gets transformed into the normal “params” argument and  
how exactly does that happen? Is it configurable? etc.

Pointing to the code that does this would work too.

I’m not sure I’m being clear but I hope so.

Thank you,  
pedz

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [May 21, 2008, 12:01am UTC](https://www.ruby-forum.com/t/activeresource-server/138191/2 "2008-05-21T00:01:48Z")

</div>

Isn’t this just a matter of setting up your rails app RESTfully?

I don’t think you have XML coming in from the client–just HTTP  
requests, with a URI (from which the routing magic derives many incoming  
parameters, just like it does when a request comes from a browser) and  
verbs (get/post, etc.) and session vars. From the point of view of your  
app, you don’t care whether the request came from a browser or an active  
resource client–communication happens, things get created, moved  
around, deleted, etc. 😉

Probably some of that is wrong–but my understanding is that the main  
reason you’d bother with the REST stuff is that you wind up w/an  
automatable application.

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [May 21, 2008, 1:04am UTC](https://www.ruby-forum.com/t/activeresource-server/138191/3 "2008-05-21T01:04:38Z")

</div>

I think that is all correct but I’ve never seen anyone talk about how  
the xml input gets remapped.

Thats the part that I’m trying to understand in particular.

Thanks

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [May 21, 2008, 1:18am UTC](https://www.ruby-forum.com/t/activeresource-server/138191/4 "2008-05-21T01:18:35Z")

</div>

On 21 May 2008, at 00:04, Perry S. wrote:

> I think that is all correct but I’ve never seen anyone talk about how  
> the xml input gets remapped.

IIRC, it’s via ActiveRecord’s from\_xml method

Fred

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [May 21, 2008, 2:26am UTC](https://www.ruby-forum.com/t/activeresource-server/138191/5 "2008-05-21T02:26:33Z")

</div>

Frederick C. wrote:

> On 21 May 2008, at 00:04, Perry S. wrote:
> 
> > I think that is all correct but I’ve never seen anyone talk about how  
> > the xml input gets remapped.
> 
> IIRC, it’s via ActiveRecord’s from\_xml method
> 
> Fred

Thanks! I grep’ped around and found where  
parse\_formatted\_request\_parameters does the magic.

Thank you again…

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [May 21, 2008, 3:30am UTC](https://www.ruby-forum.com/t/activeresource-server/138191/6 "2008-05-21T03:30:52Z")

</div>

@Perry,

Just to be clear… You have one app with RESTful routes that does  
all the typical stuff that you expect to do using ActiveRecord.  
Normal forms posting to create and update, etc. If you’ve used the  
‘normal’ scaffolded controllers you don’t need to do anything new  
here.

Then there’s the "ActiveResource’ application. This application does  
the same basic thing as the previous one with respect to HTTP  
requests. The difference is that the ActiveResource models use  
something similar to ‘formated\_model\_path(@model, :xml)’ to do CRUD.  
That means they don’t send requests in XML – they send ‘normal’ http  
requests and ask for the response in XML. ActiveResource _consumes_  
xml (ActiveResource::Base#load\_attributes\_from\_response). The onus is  
on the ActiveResource model to parse XML, not your controllers.

HTH,  
Andyv

On May 20, 8:26 pm, Perry S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
