开发者

Push updates to page in Rails

I want to try building a messaging app in Rails and I encountered a problem.

In a chat app, I need to push the messages to "USER2" as soon as "USER1" sends the开发者_StackOverflow社区m (and in the opposite directon). How can I implement some code to allow it to happen?


http://juggernaut.rubyforge.org/ - This is one of the obvious answers.

But if you're building a chat app, I'd suggest not using rails for the actual chat part. Take a look at node. Node is a lot faster than rails and it is tuned specifically for server push. Using Socket.IO with node makes a chat app take about 10 minutes of work, with the resulting app being both scalable, and backward compatible with older browsers(by using the best available transport layer for your data, choosing of 5 options). You can bridge Rails and Node in several different well-documented ways. One of those ways is by using a Redis pub-sub layer. Or, if your app is really simple, just do the whole thing in Node.

TL;DR: Use Rails for authentication, views and what-have-you, use NodeJS for the actual chat part.


If you can't/don't want to implement the client side routing logic yourself then you could use pusherapp to handle that for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜