# \<someClass railsIsEasy="true" to\_xml\_is\_easy="false"\> \</some

**URL:** <https://www.ruby-forum.com/t/someclass-railsiseasy-true-to-xml-is-easy-false-some/114738>\
**Category:** Rails\
**Created:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/someclass-railsiseasy-true-to-xml-is-easy-false-some/114738 "2007-09-17T13:24:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yottameter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/df705f/32.png) [@yottameter](https://www.ruby-forum.com/u/yottameter)\
**Post date:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/someclass-railsiseasy-true-to-xml-is-easy-false-some/114738/1 "2007-09-17T13:24:59Z")

</div>

The following code will render the subject:

format.xml { render :xml =\>  
@someClass.to\_xml(:except=\>SomeClass.column\_names)}

BUT I’m having a hard time with adding attributes railsIsEasy=“true”  
and to\_xml\_is\_easy=“false”, which are values of methods in the class.  
The :method option will only add another tag, it won’t add it as an  
attribute in the xml tag. Before I code my own to\_xml, I thought I’d  
ask to see if there is something I’m missing. I don’t see anything in  
the api that mentions an xml attribute, except for the type in the db.

---

<div class="post-metadata">

**Author:** ![yottameter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/df705f/32.png) [@yottameter](https://www.ruby-forum.com/u/yottameter)\
**Post date:** [September 25, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/someclass-railsiseasy-true-to-xml-is-easy-false-some/114738/2 "2007-09-25T23:07:39Z")

</div>

On 9/14/07, Yottameter [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ask to see if there is something I’m missing. I don’t see anything in  
> the api that mentions an xml attribute, except for the type in the db.

You’ll just have to override it to produce custom XML. Look at the  
actual implementation of #to\_xml, I believe you can use  
options[:builder] as an Xml::Builder instance and use that to build  
your custom XML.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![yottameter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/df705f/32.png) [@yottameter](https://www.ruby-forum.com/u/yottameter)\
**Post date:** [September 25, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/someclass-railsiseasy-true-to-xml-is-easy-false-some/114738/3 "2007-09-25T23:12:03Z")

</div>

Ok, already done, thought I would check for a more elegant solution.  
Thanks for the reply.
