I ran into a few hurdles when trying to use a public and private chat system in my rails 3 application. I looked at faye, juggernaut, node.js and more. In the end, having tried several approaches, I was able to implement a system that works fine:
1) I started by watching a video tutorial on faye messaging in Railscast 260 , as mentioned by Devin M. I was able to quickly set up a rails application that saved messages, and a chat server that pushed these new messages to all clients. The biggest problem was security. I did not control access to the chat server.
2) This led me to use the private Ryan Bates banner in Railscast 316 , which helps protect your faye server by verifying the clientβs signature. This worked to protect the server, but I ran into problems trying to verify the actual user using my authentication system and adding the "who is online" functionality. I worked on hacking a private pub in order to pass user details during authentication, but could not get things to work smoothly.
3) In the end, I decided to move the chat server to pusher - a hosted API for real-time applications. I followed this guide on how to create a real-time survey in rails to understand how to set it up. Although this is not directly related to setting up a chat system - this tutorial, along with what I already installed from Railscasts above (and easily readable pusher documents), allowed me to quickly set up a secure solution for 3 chats - complete with authentication, "who's online ", status messages, and more. The best part ... I do not need to deal with the management of the chat server.
Hope this helps someone get through the same process as me.
source share