Ruby on rails and Node.js

0 votes
asked Aug 20, 2010 by user425891

I am wondering how to integrate node.js on a rails app (for learning purpose).

Based on Michael Hartl tutorial ( I realized a basic twitter clone with rails and want to get user microposts in real-time without the use of comet or juggernaut. (the application is hosted on heroku)

For the moment, I only see example with node.js frameworks ( but nothing merged with a ruby on rails app. I would be very thankful if someone knows a good tutorial or give me some points to start in order to accomplish this.


4 Answers

0 votes
answered Aug 20, 2010 by shripad-krishna

If you are looking at creating real-time apps then go with node.js (high concurrency) alone. You really cannot integrate node.js into a rails app. You can however have a node server setup on another port with an api and websockets configured and then have your rails app communicate with that server. It is PITA to do that kind of setup. You rather build the entire web app in node itself. However, if you want anything rails specific that does not use juggernaut then i would suggest

Its extremely easy to setup server push using Pusher.

0 votes
answered Aug 20, 2010 by andy-atkinson

As Shripad said, I'd consider trying to build your app with Node by itself. Geddy will feel familiar (getting started anyway) if you have experience with Rails. Note: I do not have experience on a real world app with Geddy, but it is the best Rails-like framework I've seen so far. For persistence you can use SQLite, PostgreSQL or CouchDB, just like you would with Rails. I thought about how to communicate between a Rails app and Node without any intermediary. In our work project we're using Redis as an intermediary between Rails and Node. Rails publishes messages to Redis, Node pulls messages from Redis. I could not find a good way or example projects to avoid the middle communication layer on a personal project, so I went with the same setup. The good news is Node Redis modules are written and once you get everything installed, it is easy to test out pushing messages back and forth.

0 votes
answered Aug 22, 2011 by ptdorf

It already did. Not really NodeJs but a framework built on top if it. Yada, yada, yada... check this out:

0 votes
answered Sep 15, 2017 by philip-mutua

**Run node along side your rails server**

If you want to intergrate your Rails app with Node you could use the node-rails gem

Node Rails will enable you to run a Node server along side your Rails application and have the two share authentication NodeRails assumes you are using Devise for your authentication. Node-Rails uses [redis gem][2] , so you will need to have that installed. Learn more about using npm packages on Rails.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter