如何在Rails 3中创建Atom订阅?

4
我正在尝试从我的“Posts”模型设置一个简单的Atom Feed,并且在Rails 2和Rails 3之间遇到了翻译问题。
我尝试通过以下两个步骤完成此任务:
1. 将<%= auto_discovery_link_tag(:atom) %>添加到我的/views/layouts/application.html.erb文件中。 2. 创建/views/posts/index.atom.builder文件。该文件包含:
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

我在浏览器中看到了RSS链接,但是打开链接时出现了错误:

  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.

我哪里出了问题?

2个回答

7
尝试指定一个源的路径: ```

尝试指定一个源的路径:

```
<%= auto_discovery_link_tag(:atom, posts_path(:atom)) %>

2
也许您需要指定实际的订阅地址?
auto_discovery_link_tag :atom, "http://mysite.com/posts.atom"

如果您正在使用FeedBurner,则需要使用该地址。
另外,您是否有一些before_filter来阻止访问该页面?

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接