Can I bundle ruby on rails app in electron


#1

I have a requirement to build ROR + MongoDB offline app to run as desktop application. I have never used electron before, is it possible to bundle it in a desktop application and also will it run in a machine where ROR and mongo is not even installed?


#2

Electron will run on a machine that doesn’t have Rails or MongoDB installed, yes. But Electron doesn’t allow you to bundle up web applications. It allows you to write desktop applications using the web technologies you’re already familiar with: HTML, CSS, and JavaScript. So you could rewrite the application you have using Electron … and perhaps reuse some things that are already written in HTML, CSS and JavaScript. But you would still have to find a replacement for MongoDB. And Electron isn’t designed to primarily build CRUD apps like Rails is … so you might find the API lacking in some things that you’re used to compared to Rails.


#3

So my requirement is to build a CRUD desktop app which will save data in some database may be sqllite or mongodb. For now I have built a TODO app which saves data in localstorage, but in my case I need actual database. So is it possible to do it with electron?


#4

Yes, it is possible. There are a number of database interface libraries available for Node.


#5

So if suppose I want to go with mogodb, does it mean that the clients machine should be pre installed with mongodb? Or can I package mongodb with the installer file?


#6

That part you’ll probably have to figure out on your own. I have no experience with MongoDB, how to install or package it.


#7

MongoDB is quite large to be distributing with your app, which will already be around 175BM. If that is not a concern, you would then have to write a script (which would be platform dependent) to install, configure, and fire up the mongo server for you. Then you can either leave the server running on the user’s computer, or shut it down when the user shuts down the app; again this would use a platform dependent script.

If you want a PoC, it is likely easiest to use one of the embedded JS dbs that mimic the Mongo APIs. One is NeDB, but it is restricted to a single document per database instance. Another is TingoDB which allows the use of Mongoose at the data access layer if you are accustomed to using that sort of thing. TingoDB supports BSON, so you can more easily migrate your data by importing into Mongo. TingoDB has an issue with Windows that we are looking into solving for our offline project.