加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 03:44:38 所属栏目:百科 来源:网络整理
导读:我正试图从我的Posts模型中设置一个简单的原子进给,我遇到了rails 2和rails 3之间的转换问题. 我尝试通过两个步骤完成此任务: 添加了%= auto_discovery_link_tag(:atom)%到我的/views/layouts/application.html.erb文件. 创建了/views/posts/index.atom.
我正试图从我的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)) %>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读