Rails AtomFeedBuilder Entry :Url option appears in url tag but not in link tag

Posted by Nick on Stack Overflow See other posts from Stack Overflow or by Nick
Published on 2010-04-01T15:51:15Z Indexed on 2010/04/01 15:53 UTC
Read the original article Hit count: 547

Filed under:
|
|

Hello,

I'm using the AtomFeedHelper and everything is working fine except for one feed where I need to link each entry to a URL which is not the default polymorphic_url for the record.

Per the documentation I've specified an :url option for the entry. This correctly renders a <url> tag in the atom node but the <link rel="alternate" still points to the default polymorphic_url. Looking at the source and the documentation I don't understand why this is happening.

Here's an example builder:

atom_feed do |feed|
  feed.title("Reports")
  feed.updated(@reports.first.created_at)
  for report in @reports
    content = report.notes

    feed.entry(report) do |entry|
      entry.title(report.title)
      entry.content(content, :type => 'html')
      entry.url("http://myhost/page/")
      entry.updated(report.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ"))
      entry.author do |author|
        author.name(report.user.username)
      end
    end
  end

end

Here's an example of a problem node:

 <entry>
    <id>tag:molly.recargo.com,2005:SiteReport/2</id>
    <published>2010-03-30T13:11:07-07:00</published>
    <updated>2010-03-30T13:11:07-07:00</updated>
    <link rel="alternate" type="text/html" href="http://myhost/site_reports/2"/>
    <title>Test Title</title>
    <content type="html">Test Content</content>
    <url>http://myhost/page/</url>
    <updated>2010-03-30T13:11:07Z</updated>
    <author>
      <name>Author</name>
    </author>
  </entry>

I wan the href value in the link tag to match the value in the url tag but it does not.

When I look at the source listed for entry here http://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper/AtomFeedBuilder.html

I'd assume that this line would work correctly:

 @xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:url] || @view.polymorphic_url(record))

Confused. Has anyone encountered this before?

Thanks all!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about atom