· 1 min read
Screencast: Polling nach Aktualisierungen
Download:
Download(23.2 MB, 16:07) Alternativer Download für iPod & Apple TV(22.3 MB, 16:07)
Resourcen:
Quellcode:
[bash] bundle install rails g jquery:install [/bash]
[ruby] # Gemfile gem ‘jquery-rails’
# comments_controller.rb def index @comments = Comment.where(“article_id = ? and created_at > ?”, params[:article_id], Time.at(params[:after].to_i + 1)) end [/ruby]
[html] <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %>
...
<% unless @comments.empty? %> $("#comments").append("<%=raw escape\_javascript(render(@comments)) %>"); $("#article h2").text($(".comment").length + " comments"); <% end %> \[/html\]