title: User Presence In a chat room (chat getting updated by simple polling)
body: <p>We have implemented a simple chat room feature in Rails using Simple Ajax updates. Now in every chat room a message belongs to particular user. We want to show the list of users(something like user presence). Please suggest ways. We are not using Jabber,XMPP etc. </p>
  
  <p>The Chatroom model is:</p>
  
  <pre><code>class ChatRoom &lt; ActiveRecord::Base
    validates_presence_of :title
  
    has_many :messages,:foreign_key=&gt; "chat_room_id"
    has_many :stories,:foreign_key=&gt;"chat_room_id"
    has_many :topics,:foreign_key=&gt;"chat_room_id"
  
  
  end
  </code></pre>
  
  <p>The messages are the chats sent  of every user.</p>
  
  <p>The message model is:</p>
  
  <pre><code>class Message &lt; ActiveRecord::Base
    belongs_to :user
  end
  </code></pre>
  
  <p>The USer model is:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    acts_as_authentic :crypto_provider =&gt; Authlogic::CryptoProviders::BCrypt
    validates_presence_of :nick
    validates_uniqueness_of :nick
    has_many :questions
    end
  </code></pre>
  
  <p>Please suggest ways</p>