Ruby on Rails 和 Node.js

问题描述:

我想知道如何将 node.js 集成到 Rails 应用程序上(用于学习目的).

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

基于 Michael Hartl 教程 (http://railstutorial.org/),我实现了一个基本的 twitter 克隆rails 并希望在不使用 Comet 或 juggernaut 的情况下实时获取用户微博.(该应用程序托管在 heroku 上)

Based on Michael Hartl tutorial (http://railstutorial.org/) 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)

目前,我只看到 node.js 框架的示例(http://howtonode.org/grasshopper-shoutbox) 但没有与 ruby​​ on rails 应用程序合并.如果有人知道一个好的教程或给我一些要点来完成这个,我将非常感激.

For the moment, I only see example with node.js frameworks (http://howtonode.org/grasshopper-shoutbox) 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.

谢谢!

正如 Shripad 所说,我会考虑尝试单独使用 Node 构建您的应用程序.如果您有使用 Rails 的经验,Geddy 会觉得很熟悉(无论如何都是入门).注意:我没有使用 Geddy 开发真实世界的应用程序的经验,但它是迄今为止我见过的最好的类似 Rails 的框架.对于持久性,您可以使用 SQLite、PostgreSQL 或 CouchDB,就像使用 Rails 一样.我想过如何在没有任何中介的情况下在 Rails 应用程序和 Node 之间进行通信.在我们的工作项目中,我们使用 Redis 作为 Rails 和 Node 之间的中介.Rails 向 Redis 发布消息,Node 从 Redis 拉取消息.我找不到一个好的方法或示例项目来避免个人项目中的中间通信层,所以我采用了相同的设置.好消息是编写了 Node Redis 模块,一旦您安装了所有内容,就可以轻松测试来回推送消息.

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.