Rails 5 comes up with Action Cable and it is a wonderful feature as usually to do a real time feature. In the past we would need to rely on NodeJS to have implement a websocket. This is only the backend api and you will need link it up to a frontend view to render the chat messages.
I have built a ReactJS front end which can be viewed here: