11

I am building a real time chat into a rails 4 application. It seems ActionCable is the tool for this kind of job.

Is it possible to use ActionCable in rails 4 or do I have update to rails 5?

I cannot find any introduction for ActionCable with rails 4.

4

2 回答 2

10

ActionCable 只是一种处理 websocket 的 rails-5 方式。对于当前的 Rails,有 Faye( https://github.com/faye ) 和多个包装器,如 private-pub 和 faye-rails。

此外,您根本不必在 ruby​​ 中编写 websocket 处理程序

于 2016-03-21T16:18:22.783 回答
8

Rails 本身就是各种 Rubygem 的集合。ActionCable 只是 Rails 5 添加到集合中的一个新 gem。您可以通过 Gemfile 自行安装 ActionCable:

gem 'actioncable', '~> 5.0.0.beta3'

然后就去设置它。这是一篇不错的文章:

http://www.thegreatcodeadventure.com/rails-5-preview-action-cable/

于 2016-03-21T16:36:24.880 回答