Ruby on Rails 3 - Public Chat

I want to create a public chat application using rails 3.

I found an example on rails 2. Anyone can tell you a good example / tutorial on developing a chat application using rails 3.

+6
source share
3 answers

I would start by checking Ilya Grigorik em-synchony + examples and see the Hector code for a personal chat server.

+3
source

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.

+7
source

You can get the basics with Railscast 260 , I assume Rails / Ruby already has a background and some jQuery / JavaScript knowledge. The screencast has a text version here and a source here , as well as on GitHub .

+6
source

Source: https://habr.com/ru/post/895654/


All Articles