# Empty\_model.to\_xml with attr\_accessor attributes?

**URL:** <https://www.ruby-forum.com/t/empty-model-to-xml-with-attr-accessor-attributes/136816>\
**Category:** Rails\
**Created:** [May 6, 2008, 5:11pm UTC](https://www.ruby-forum.com/t/empty-model-to-xml-with-attr-accessor-attributes/136816 "2008-05-06T17:11:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joergbattermann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joergbattermann](https://www.ruby-forum.com/u/joergbattermann)\
**Post date:** [May 6, 2008, 5:11pm UTC](https://www.ruby-forum.com/t/empty-model-to-xml-with-attr-accessor-attributes/136816/1 "2008-05-06T17:11:44Z")

</div>

Hello there,

I have an empty Asset model which only contains 3 attr\_accessor  
attributes (:uploaded\_data, :title, :description), which I can fill  
just fine using form\_for etc, but when trying to do it restfully, the /  
assets/new.xml just returns an empty

\<?xml version="1.0" encoding="UTF-8"?\>

Is there a way to serialize / @asset.to\_xml including the  
uploaded\_data/title/description attributes?

format.xml { render :xml =\> @asset.to\_xml(:only =\>  
[:uploaded\_data, :title, :description]) } returns the same as  
above… :-/

Thanks,  
-Jörg
