簡體   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