Rails RSS 只输出 20 篇文章, Google reader 却可以记录全部

xiaoronglv · 2012年11月14日 · 最后由 xiaoronglv 回复于 2012年11月15日 · 2874 次阅读

Ruby-China 的代码中,某个主题下,RSS 只输出最近的 20 篇文章,代码如下。

def node_feed
    @node = Node.find(params[:id])
    @topics = @node.topics.recent.without_body.limit(20)
    response.headers["Content-Type"] = "application/rss+xml"
    render :layout => false
end

可是在 RSS 阅读器中,比如 google reader. 可以阅读 RSS 曾经输出的所有文章?

Google 记住了历史记录?

RSS 技术一直没有推广开

#2 楼 @ery 看不懂,稍微细说一下? 😄

#3 楼 @xiaoronglv web2.0 的时候, 业内认为 RSS 将成为一种主流工具,就像今天的 IM, 可是如今,只有 Geek 在用 RSS。

RSS 是没有围墙的微博,正如 email 是没有围墙的 IM,没有围墙,也没有了统一的规则

上面一段代码是 RailsCast 中的一个 builder, 生成 feed 专用。

网址: http://railscasts.com/episodes/87-generating-rss-feeds-revised?view=asciicast

代码是不是有问题啊?我怎么感觉应该写成下面这种格式?

atom_feed do |feed|
  feed.title "Superhero Articles"
  feed.updated @articles.maximum(:updated_at)

  @articles.each do |article|
    feed.entry do |entry|
      entry.published article.publisherd_at
      entry.title article.name
      entry.content article.content
      entry.author do |author|
              author.name article.author
      end
    end
  end
end

需要 登录 后方可回复, 如果你还没有账号请 注册新账号