【发布时间】:2014-06-28 08:53:32
【问题描述】:
我使用 websocket 在 Rails 中创建 web 应用程序。我在 routes.rb 中创建 add 下面
get '/:username' => 'users#profile', as:"profile"
在此之后,我在 Gemfile 中添加波纹管
gem 'websocket-rails'
然后我在 application.js 中添加以下内容
var dispatcher = new WebSocketRails('localhost:3000/websocket');
channel = dispatcher.subscribe('articles');
channel.bind('new', function(article) {
console.log('a new article about '+article.id+' arrived!');
})
问题是
localhost:3000/websocket =====> 运行 profile_path (get '/:username' => 'users#profile', as:"profile")
如何在不删除 { get '/:username' => 'users#profile', as:"profile" }.. 的情况下解决我的 websocket 问题?
我是使用 web socket 开发 rails 的新用户。
【问题讨论】:
标签: ruby ruby-on-rails-4 websocket routes