How to properly run a Rails app inside Electron?


#1

I am very new to Electron, just tried to follow the Documentation.

I was able to run a html in Electron and it worked fine.

Then I tried to load a Rails app with BrowserWindow loadUrl, but the javascripts of the app are not working inside Electron.

My main is this index.js here:

var app = require ('app')
var BrowserWindow = require ('browser-window')
app.on('ready', function(){
    var mainWindow = new BrowserWindow({
        width:1115,
        height:945
    })
    mainWindow.loadUrl('http://my-app-at-heroku.herokuapp.com')
})

Running the server in my machine and loading http://localhost:3000 has the same behavior. The app appears, but the js doesn’t work.

What have I missed? How do I properly run a Rails app inside Electron?


#2

Are there any js errors in the console? My initial guess is a problem with cross site script protection.


#3

The error was that jQuery was not defined.

But I just found out the solution.

In my Rails app, I just added the following code in the header:

<script type="text/javascript">
      window.module = undefined;
      window.require = undefined;
</script>