The ELC Community Blog
A knowledge exchange on Ruby on Rails and Agile Development
acts_as_chattable: make web chatting easy
by Yuanyi Zhang on December 07, 2007
acts_as_chattable is a plugin which allows you to integrate a user-to-user chatting system into your Rails app in minutes.
Installationscript/plugin install http://svn.elctech.com/svn/public/plugins/acts_as_chattableDemo
svn co https://svn.elctech.com/svn/public/demo/acts_as_chattableUsage
At first, I assume you have a ‘User’ model and it own a ‘name’ method which will return user‘s chatting name. If you don‘t have these yet, create them and let‘s go!
1. Install Juggernaut, acts_as_chattable needs Juggernaut to get PUSH support.
script/plugin install svn://rubyforge.org//var/svn/juggernaut/trunk/juggernaut
2. Generate chat_controller.
script/generate chattable
3. Render chat in views
<%= render_chat(user, friends) %> <%= buddy_list(friends) %>
- user should be current_user which will be used to create a Juggernaut channel.
- friends should be an array of user which presents current user's friends.
You can use chat_link(friend) to generate buddy_list customly, it will return a link which will open a chat window with this friend.
More documents are available at:http://letrails.cn/plugins/acts_as_chattable
4. At last, Don‘t forget to start push_server.
ruby script/push_server ruby script/server
5. It's done! Open your browser and start chatting.
Comments and feedback are welcome!
A Chinese version is also available here.

Timeline
- Patching Rails - Rendering form partials
- Open Social plugin progress report
- Notify me when it's done
- OpenSocial on Rails, finally 1.0
- Testing without the database
- acts_as_chattable: make web chatting easy
- OpenSocial Container 0.3.0
- OpenSocial Container 0.2.0
- Mephisto Flickr AJAX Loader
- OpenSocial? What's that?
- Ruby on Rails, OpenSocial Container plugin 0.1.0
Comments
yuanyi,
I am a rails newbie and trying to use your plugin on my web. It seems not working yet. Can you tell me what columns I need to have on my friends table? Currently, I made a friends table and have id(primary key), user_id, name (which is a friend’s name) columns. I need a little help. Please let me know. Thanks
Hi, Jay, thank you for trying this plugin, it’s on v0.2 currently, and I’ve updated the post to reflect the changes.
Only two steps are needed in the latest version, if you still can’t get it running, try to check out the demo, if the demo doesn’t work, please let me know, you can contact me via yzhang AT elctech DOT com, thanks.
Do you have the resolution for Cannot Connect to server. Thanks
I also get a cannot connect message for the demo. I got the demo, created the acts_as_chattable_development database, ran the migrations, downloaded rails 1.2.6, uninstalled rubyforge 1.0.0 (there is some conflict where 1.0.0 loads first and i guess the demo needs some older version like 0.4.5), ran script/server, created a new user, logged in and got the connection failed error. Then I realized I hadn’t started juggernaut, so I tried to start it with the juggernaut -g juggernaut.yml and then juggernaut -c juggernaut.yml. Server started up and I refreshed the browser and received the same error: connection to juggernaut failed.
will this work with the latest copy of juggernaut? thanks!