# Atom\_builder and link element

**URL:** <https://www.ruby-forum.com/t/atom-builder-and-link-element/161716>\
**Category:** Rails\
**Created:** [March 1, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/atom-builder-and-link-element/161716 "2009-03-01T17:02:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KevinJones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@KevinJones](https://www.ruby-forum.com/u/KevinJones)\
**Post date:** [March 1, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/atom-builder-and-link-element/161716/1 "2009-03-01T17:02:50Z")

</div>

I’m using the atom builder to build a feed. It’s mostly working but  
the value in the link element of each entry is not being generated as  
it needs to be.

My url scheme looks like [http://example.com/blog/nickname/id](http://example.com/blog/nickname/id)

I have a controller called blog\_entries and a routes.rb file which a  
seet of maps for blog\_entries, it looks something like this (amongst  
all the other routes):

map.blog\_entries ‘blog/:nickname’,  
:controller =\> “blog\_entries”,  
:action =\> “index”,  
:conditions =\> {:method =\> :get}  
map.formatted\_blog\_entries ‘blog/:nickname.:format’,  
:controller =\> “blog\_entries”,  
:action =\> “index”,  
:conditions =\> {:method =\> :get}

In my views, to generate the correct URLs for links I do something  
like:

\<%= link\_to ‘New Entry’, new\_blog\_entry\_path(:nickname =\>  
@blog.nickname) %\>

and this creates the correct path.

The builder code looks like:

feed.entry(post) do |entry|  
entry.title post.title  
etc…  
end

The problem is the generated link in the atom output, it looks like

when what I need is

I’ve tried

entry.link :href =\> “some other url”

but that adds a second link entry into the output which is in the  
wrong place in the XML so is ignored by readers.

So, can I hook into the url generation mechanism to get the nickname  
value into the URL, or  
can I tell the builder to use “nickname” when generating the url?

If not I guess the other thing is to generate the atom feed myself,  
seems a shame not to use the builder though.
