ActiveResource xml element ordering

I haven't, but e.g. the Builder API looks pretty straightforward:

  http://api.rubyonrails.org/classes/Builder/XmlMarkup.html

:: and includes examples; maybe you should just try that and come back if you have a specific problem :slight_smile:

thanks, I am not sure how to make my model convert to xml for POST according to builder rules... currently it uses a hash to represent all fields and calls hash.to_xml but hash is unordered so no predictability. this is my specific problem :slight_smile:

Hassan Schroeder wrote:

I am stuck.. here is what i tried class SalesDocument < ActiveResource::Base   def encode     SalesDocumentsController.new.render_to_string :template, 'rxml-file'   end end

But that does not work. I get:

NoMethodError: protected method `render_to_string' called for #<SalesDocumentsController:0xb6fd111c>

Are we talking about the same thing? How that even begins to relate to   <http://api.rubyonrails.org/classes/Builder/XmlMarkup.html&gt; escapes me...

Slava Mikerin wrote:

ok. I found solution :slight_smile: Here is what I did

class SalesDocument < ActiveResource::Base   def encode     builder = Builder::XmlMarkup.new(:indent=>2)

Cool. BTW, it's more idiomatic Ruby to use do/end for multiline blocks and save { } for one-liners.

Best,