1

I have a rails app which is the REST api. Part of the models i have are javascript scripts that the users are able to upload.

I want to create a background worker task where i can make a network request and execute the javascript on the result of the network request server side and then save it to the database.

Now i have been told to consider using a Rails front end api and then use a NodeJS server for being the workers and executing javascript.

My main concern is developing a cross platform schema with nodejs orm and rails orm.

So my question is twofold is there a way of developing the database schema so it is in sync across both the Node JS server and the Rails server. Else is there a way of executing the javascript on the rails server?

1 Answer 1

2

You can use https://github.com/balderdashy/waterline or https://github.com/sequelize/sequelize or https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Shell to access same database as Rails app from Node.js app but make sure that you are only reading from database using Node.js not writing

2
  • pardon my ignorance but what would be the issue if i had the node.js app do any writing? I can architect it so that the workers go through the rails app to write the results of the workers but is it an ORM/database issue or is it an architecture issue? Apr 29, 2015 at 0:30
  • 1
    I assumed that as an architectural issue, because instead of making these two applications to write to the same database you can make the node.js application to send messages to the Rails app using any messaging service (e.g RabbitMQ) and then make only Rails application to deal with database. The reason is that making two applications to write to same database may cause hidden errors later and it'll double your effort to implement everything in both of them, if you need to add before_save call back for example. Apr 29, 2015 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.