Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an atom feed in Rails 3?

I'm trying to set up a simple atom feed from my Posts model and I'm running into translation problems between rails 2 and rails 3.

I tried to accomplish this task with two steps:

Added the <%= auto_discovery_link_tag(:atom) %> to my /views/layouts/application.html.erb file.

Created a /views/posts/index.atom.builder file. The file contains:

atom_feed do |feed|   
  feed.title("Daily Deal")   
  feed.updated(@posts.first.created_at)
  @posts.each do |post|
    feed.entry(post) do |entry|
      entry.title(post.title)
      entry.content(post.body, :type => 'html')
      entry.author { |author| author.name("Justin Zollars")}
    end
  end
end

I see the RSS link in my browser, but the link opens with an error:

  Too many redirects occurred trying to open
  “feed:http://localhost:3000/posts”.
  This might occur if you open a page
  that is redirected to open another
  page which then is redirected to open
  the original page.

Where have I gone wrong?

like image 473
JZ. Avatar asked Jan 21 '23 17:01

JZ.


1 Answers

Try specifying a path to the feed:

<%= auto_discovery_link_tag(:atom, posts_path(:atom)) %>
like image 68
John Topley Avatar answered Jan 29 '23 16:01

John Topley