# Creating a chat application from scratch using Rails and WebSockets

DevFeed: [Creating a chat application from scratch using Rails and WebSockets](<https://devfeed.tech/articles/creating-a-chat-application-from-scratch-using-rails-and-websockets-37443.md>)

Original publisher: [Read original article](<https://iridakos.com/programming/2019/04/04/creating-chat-application-rails-websockets>)

Author: Lazarus Lazaridis

Published: 2019-04-04T20:00:00Z

Content type: tutorial

Language: en

Sources: [Lazarus Lazaridis](<https://devfeed.tech/sources/lazarus-lazaridis.md>)

Topics: [WebSocket](<https://devfeed.tech/topics/websocket.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [actioncable](<https://devfeed.tech/tags/actioncable.md>), [application](<https://devfeed.tech/tags/application.md>), [bootstrap](<https://devfeed.tech/tags/bootstrap.md>), [chat](<https://devfeed.tech/tags/chat.md>), [code](<https://devfeed.tech/tags/code.md>), [devise](<https://devfeed.tech/tags/devise.md>), [featured](<https://devfeed.tech/tags/featured.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rails](<https://devfeed.tech/tags/rails.md>), [redis](<https://devfeed.tech/tags/redis.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>), [websocket](<https://devfeed.tech/tags/websocket.md>), [websockets](<https://devfeed.tech/tags/websockets.md>)

## AI overview

A tutorial for building a chat web application from scratch with Rails and WebSockets. It explains WebSocket bidirectional communication and real-time data transfer, then introduces the Ruby and Rails versions used for the application.

## Source excerpt

Hey! It's been a while since my last post. I recently familiarized myself with the awesomeness of WebSockets and I finally found the time to write a tutorial about it. I hope you find it helpful. Update: I also published another post for dockerizing the application of this tutorial, you can find it here. Introduction In this tutorial we are going to create a chat web application from scratch using Rails and WebSockets. Code and comments You can find the code of this tutorial on GitHub. For feedback, comments, typos etc. please open an issue in the repository. What are WebSockets WebSocket is actually a protocol that enables bidirectional communication between the client and the server of a web application over a single long living TCP connection. The WebSocket protocol enables interaction between a web browser (or other client application) and a web server with lower overheads, facilitating real-time data transfer from and to the server. This is made possible by providing a standardized way for the server to send content to the client without being first requested by the client, and allowing messages to be passed back and forth while keeping the connection open. In this way, a two-way ongoing conversation can take place between the client and the server. The communications are done over TCP port number 80 (or 443 in the case of TLS-encrypted connections), which is of benefit for those environments which block non-web Internet connections using a firewall. Similar two-way browser-server communications have been achieved in non-standardized ways using stopgap technologies such as Comet. - WebSocket @ Wikipedia Why WebSockets Suppose you have to create a web page that shows the statuses of running processes. Without WebSockets you would have to either: Use AJAX with Javascript intervals to request and render the latest state of the processes or Automatically reload the page every x seconds (<meta http-equiv="refresh" content="x">) or Add a message on the page "The stat