Integrate ConverseJS with Rails The Easy Way

If you ever needed to add chat to your Rails app, than you are probably familiar with the ConverseJS library, which is a great XMPP/Jabber compatible javascript client. But until today there was no asset-pipeline compatible gem that would add converse.js and converse.css to your app. As you probably know, adding external js and css files manually isn’t ideal, since it makes it harder to maintain and update versions.

Well, now there is: https://github.com/mikemarsian/conversejs-rails/

Just add the following to your Gemfile:

And add the following directive to your Javascript manifest file (application.js):

In case you receive weird javascript errors, that might be a sign that there are conflicts between your existing javascript files and converse. To solve this, try adding converse.js and converse.css in your layout file after all other javascripts, instead of adding a directive to manifest file, which doesn’t always guarantee order.

And that’s it.

Leave a Reply

Your email address will not be published. Required fields are marked *