繁体   English   中英

如何在Rails 3中创建原子提要?

[英]How to create an atom feed in Rails 3?

我正试图从我的Posts模型中设置一个简单的原子进给,我遇到了rails 2和rails 3之间的转换问题。

我尝试通过两个步骤完成此任务:

在我的/views/layouts/application.html.erb文件中添加了<%= auto_discovery_link_tag(:atom) %>

创建了/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.

我哪里出错了?

尝试指定Feed的路径:

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

也许您需要指定实际的Feed地址?

auto_discovery_link_tag :atom, "http://mysite.com/posts.atom"

如果您使用的是FeedBurner,则需要使用该地址。

此外,您是否有某种before_filter阻止访问该页面?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM