Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 178425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:13:44+00:00 2026-05-11T14:13:44+00:00

We have implemented a simple chat room feature in Rails using Simple Ajax updates.

  • 0

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.

The Chatroom model is:

class ChatRoom < ActiveRecord::Base   validates_presence_of :title    has_many :messages,:foreign_key=> 'chat_room_id'   has_many :stories,:foreign_key=>'chat_room_id'   has_many :topics,:foreign_key=>'chat_room_id'   end 

The messages are the chats sent of every user.

The message model is:

class Message < ActiveRecord::Base   belongs_to :user end 

The USer model is:

class User < ActiveRecord::Base   acts_as_authentic :crypto_provider => Authlogic::CryptoProviders::BCrypt   validates_presence_of :nick   validates_uniqueness_of :nick   has_many :questions   end 

Please suggest ways

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:13:45+00:00Added an answer on May 11, 2026 at 2:13 pm

    To keep track of which users are in which room, you could set up a HABTM relationship between the ChatRoom and User models. And, you could add a last_poll_datetime column to the User model to track the last time the user polled for messages (more on this part in a minute).

    To show a list of all the users in a given room, use your HABTM join table, ChatRooms_Users. You’ll be inserting/deleting from this table whenever a user joins or leaves a room.

    If you want to expire users who close their browsers instead of clicking ‘leave room’, set up a sweeper task to run every minute that looks for users with last_poll_datetime older than one minute and remove their rows from the ChatRooms_Users join table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 103k
  • Answers 103k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Any kind of proprietary communication protocol running over UDP or… May 11, 2026 at 8:28 pm
  • Editorial Team
    Editorial Team added an answer There is no need to uninstall ASP.NET MVC from GAC!… May 11, 2026 at 8:28 pm
  • Editorial Team
    Editorial Team added an answer You cannot pass a non-static member function of a class… May 11, 2026 at 8:28 pm

Related Questions

In our desktop application, we have implemented a simple search engine using an inverted
Can we do something similar to List.Contains(myItem) in order to check if a property
For a website implemented in Django/Python we have the following requirement: On a view
We use log4net for logging application exceptions for a variety of web applications. At

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.