Forum: Ruby on Rails atom_builder and link element

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
KevinJones (Guest)
on 2009-03-01 18:02
(Received via mailing list)
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

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

<%= 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

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

<link type='....' href="" />

when what I need is

<link type='....' href="" />

I've tried :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.
This topic is locked and can not be replied to.