# Xml : why is the Model ID field missing

**URL:** <https://www.ruby-forum.com/t/xml-why-is-the-model-id-field-missing/178910>\
**Category:** Rails\
**Created:** [November 13, 2009, 11:50am UTC](https://www.ruby-forum.com/t/xml-why-is-the-model-id-field-missing/178910 "2009-11-13T11:50:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [November 13, 2009, 11:50am UTC](https://www.ruby-forum.com/t/xml-why-is-the-model-id-field-missing/178910/1 "2009-11-13T11:50:44Z")

</div>

Sorry if I’m missing something here but I’ve simply created a respond\_to  
block with an xml type in it so that user can go to [www.foo.com/foos.xml](http://www.foo.com/foos.xml)  
and get xml back. Works fine but I need the foo\_id in there and I don’t  
see it!

How can I force it’s inclusion or can you think of a reason why it might  
not be there - all the other fields for the record seem to be there as  
far as I can see?

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [November 13, 2009, 12:30pm UTC](https://www.ruby-forum.com/t/xml-why-is-the-model-id-field-missing/178910/2 "2009-11-13T12:30:09Z")

</div>

Hi

Can you paste the code? Is there id in generated xml?

Sijo

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [November 13, 2009, 1:59pm UTC](https://www.ruby-forum.com/t/xml-why-is-the-model-id-field-missing/178910/3 "2009-11-13T13:59:16Z")

</div>

Hi Sijo, thanks for the post…

Just for the record this great blog post answered it for me…

Needed to use a “builder” file, in there I can specify just how I’d like  
the XML. Genius!

> **[Generating custom XML for your rails app | Pieces of Web](http://danengle.us/2009/05/generating-custom-xml-for-your-rails-app/)**
>
> Rails provides a very simple way to generate xml. Most of the time though, it is much too verbose. Current information obtained by google does not seem to provide all the info needed to generate custom xml. Keep reading to find out how to generate...

BB

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [November 13, 2009, 5:26pm UTC](https://www.ruby-forum.com/t/xml-why-is-the-model-id-field-missing/178910/4 "2009-11-13T17:26:23Z")

</div>

You can also override the to\_xml method in the model.  
[http://api.rubyonrails.org/classes/ActiveRecord/XmlSerialization.html](http://api.rubyonrails.org/classes/ActiveRecord/XmlSerialization.html)

On Fri, Nov 13, 2009 at 4:59 AM, bingo bob  
\<removed\_email\_address@domain.invalid

> wrote:

> ## BB
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Darian Shimy
