views:

31

answers:

1

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:myhost.mydomain.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"/&gt;
    <title>Test Title</title>
    <content type="html">Test Content</content>
    <url>http://myhost/page/&lt;/url&gt;
    <updated>2010-03-30T13:11:07Z</updated>
    <author>
      <name>Author</name>
    </author>
  </entry>

I want 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!

+1  A: 

I accomplished this by passing the :url option directly to the feed.entry method:

feed.entry(report, :url => report_url(report.slug)) do |entry|

Chris Conley