1. Skip to navigation
  2. Skip to content

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
ELC Plugins

acts_as_chattable is a plugin which allows you to integrate a user-to-user chatting system into your Rails app in minutes.

Installation
script/plugin install http://svn.elctech.com/svn/public/plugins/acts_as_chattable
Demo
svn co https://svn.elctech.com/svn/public/demo/acts_as_chattable
Usage

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.

Comments

Jay at 12:52 AM on December 24 2007

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

yuanyi at 6:40 AM on January 6 2008

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.

burn at 3:08 AM on June 10 2008

Do you have the resolution for Cannot Connect to server. Thanks

Kevin at 7:18 PM on June 10 2008

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.

burn at 12:35 AM on June 18 2008

will this work with the latest copy of juggernaut? thanks!

Add a comment


home | services | Ruby on Rails Development | code | blog | company