Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Commit

Permalink
Push "Total Messages Sent"
Browse files Browse the repository at this point in the history
  • Loading branch information
dipth committed Dec 12, 2011
1 parent c8734c8 commit cdee389
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/assets/javascripts/messages.js.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

$ ->
window.broadcast_channel.bind 'total_messages_changed', (event) ->
$('#total_messages').html(event.value)
1 change: 1 addition & 0 deletions app/models/message_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ class MessageObserver < ActiveRecord::Observer
include ActionView::Helpers::TextHelper

def after_create(message)
Pusher['broadcast'].trigger!('total_messages_changed', {:value => pluralize(Message.count, 'message', 'messages')})
end
end

0 comments on commit cdee389

Please sign in to comment.