# Help with to\_xml - Add a custom tag in each ele in a coll

**URL:** <https://www.ruby-forum.com/t/help-with-to-xml-add-a-custom-tag-in-each-ele-in-a-coll/141543>\
**Category:** Rails\
**Created:** [June 26, 2008, 9:46pm UTC](https://www.ruby-forum.com/t/help-with-to-xml-add-a-custom-tag-in-each-ele-in-a-coll/141543 "2008-06-26T21:46:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![darth\_ivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@darth\_ivan](https://www.ruby-forum.com/u/darth_ivan)\
**Post date:** [June 26, 2008, 9:46pm UTC](https://www.ruby-forum.com/t/help-with-to-xml-add-a-custom-tag-in-each-ele-in-a-coll/141543/1 "2008-06-26T21:46:23Z")

</div>

Hi,

I was advised to use either the :methods option of to\_xml or use a block  
to add additional tags to the output. What I’m trying to do is add a  
permalink tag to each element in a collection, but I can’t seem to get  
it right.

If I use the :methods option of to\_xml, I’d need to access an url helper  
from a model, and I haven’t figured that out yet.

When using either a proc or a block I don’t know how to get the current  
record from the collection in order to use a url helper. For example:

render :xml =\> @messages do |options|  
options[:builder].tag!(‘permalink’, message\_url(WHAT\_DO\_I\_PUT\_HERE?)  
end

Any pointers?

Thanks in advance.

- Ivan V.
