【发布时间】:2015-06-26 20:40:50
【问题描述】:
我正在尝试在我的网站标题中显示一个 cmets 计数器,其中有几个选项:
ul
= sync_new partial: "show", resource: Commontator::Comment.new
/ also with
ul
= sync partial: "show", resource: Commontator::Comment.new
/ also with
ul
= sync_new partial: "show", collection: Commontator::Comment.all
/ also with
ul
= sync partial: "show", collection: Commontator::Comment.all
在我看来:
li
a = comment.class.all.size
我不清楚sync_new 和sync 之间的区别。
我的理解:
- 在传递集合时,同步会为集合中的每个项目呈现部分内容,显示计数器没有意义。
- 传递资源时,sync 会为传递的资源渲染部分内容,问题是当创建或销毁另一个评论时,传递的资源不会更新计数器。
也许我应该走一个完全不同的方向,比如直接使用 Faye。任何建议表示赞赏。
还发布了here。
【问题讨论】:
标签: ruby-on-rails websocket publish-subscribe faye