微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – 如何在Rails 3中创建原子提要?

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

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

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐