# Best-practice for programmatically using rxml generated from controller/view? (or 'how can I view a

**URL:** <https://www.ruby-forum.com/t/best-practice-for-programmatically-using-rxml-generated-from-controller-view-or-how-can-i-view-a/150915>\
**Category:** Rails\
**Created:** [October 14, 2008, 10:16pm UTC](https://www.ruby-forum.com/t/best-practice-for-programmatically-using-rxml-generated-from-controller-view-or-how-can-i-view-a/150915 "2008-10-14T22:16:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jashmenn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@jashmenn](https://www.ruby-forum.com/u/jashmenn)\
**Post date:** [October 14, 2008, 10:16pm UTC](https://www.ruby-forum.com/t/best-practice-for-programmatically-using-rxml-generated-from-controller-view-or-how-can-i-view-a/150915/1 "2008-10-14T22:16:29Z")

</div>

Hey Guys,

Here’s the scenario:  
I’ve got vendor-specific XML I need to create and then POST it  
somewhere. It sounds easy enough, but I’m running into issues when it  
comes time to actually use the XML.

Trying hard to stay within the MVC pattern I:

1. Create a controller which loads the models I’m about to turn into  
XML
2. Create an rxml view which renders the XML I need perfectly

Now I need to actually _use_ this XML in a “model” and POST it to the  
webservice endpoint. Now, I am not asking “how can I render a view in  
a model?”. What I am asking is “how can I view a view from a model?”

It seems logical and not a breach of MVC that the system should have  
this level of introspection (right?). It seems consistent with MVC b/c  
the view is rendering and the controller is controlling. I just need  
to use that view in an object.

The best solution I have right now is to just have an object that uses  
net/http or wget and then calls the url of my own server. But this  
seems hackish and less than ideal.

Has anyone else had to deal with a similar type of issue? Am I missing  
something incredibly obvious?

Nate

---

<div class="post-metadata">

**Author:** ![jashmenn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@jashmenn](https://www.ruby-forum.com/u/jashmenn)\
**Post date:** [October 14, 2008, 10:43pm UTC](https://www.ruby-forum.com/t/best-practice-for-programmatically-using-rxml-generated-from-controller-view-or-how-can-i-view-a/150915/2 "2008-10-14T22:43:30Z")

</div>

ActiveResource is supposed to be good for this sort of thing, isn’t it?  
Can you use that?

---

<div class="post-metadata">

**Author:** ![jashmenn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eb9ed0/32.png) [@jashmenn](https://www.ruby-forum.com/u/jashmenn)\
**Post date:** [October 14, 2008, 10:47pm UTC](https://www.ruby-forum.com/t/best-practice-for-programmatically-using-rxml-generated-from-controller-view-or-how-can-i-view-a/150915/3 "2008-10-14T22:47:01Z")

</div>

Use builder directly (which is what rxml views use)

Sent from my iPhone
